Bug 63980 - Type Cache seems to use a lot of memory
Summary: Type Cache seems to use a lot of memory
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows XP
: P1 major (vote)
Target Milestone: ---   Edit
Assignee: Chris Wiebe CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-25 16:42 EDT by David Daoust CLA
Modified: 2004-06-18 14:10 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Daoust CLA 2004-05-25 16:42:59 EDT
I have been trying the OpenType dialog with a small to midsize project (1300 
cpp files).   (Using CDT Head - from this morning, and Eclipse 3.0M9)

Here is some background on the project:

	1. The project has  been previously indexed (Image grew from 48M to 
116M, took about 9 minutes to index),  and 
	2.  Code assist and search work reasonably well (although sometimes 
quite slow).  
	3.  Closing eclipse and restarting it causes no re-indexing at all. 
(image is now 48M)
	4.  I have the "cache types in background" flag off

	5.  The first time I use the OpenType dialog (after restarting 
eclipse), it takes a minute or so to "Updating Type Cache",
	6.  Each subsequent invocation is instant.

This looks great!  

Now here is the problem:
	The memory requirements on step 5 have jumped by 160M ,   I think that 
this will not scale well....


There was no parsing being done (I have a breakpoint on Parser.translationUnit)

Has anybody else measured something similar?
Comment 1 Chris Wiebe CLA 2004-05-26 16:25:34 EDT
I've tried my own test case for this problem.  Starting with a project with
~8000 files:

1. The Indexer took ~25 minutes.  Memory usage peaked at about 272MB after 47%
done, at which point the system slowed to a crawl and became unusable (ie task
manager shows "not responding").  However I let it continue running and after a
few minutes it became responsive again.  Memory usage levelled off to around
270MB for the remaining 10 minutes.

2. The .index file on disk was ~991KB, but the .log file was 82MB, 99% of which
was this error:

MESSAGE Parser: Unexpected exception in
simpleDeclaration:createSimpleTypeSpecifier:org.eclipse.cdt.core.parser.ast.ASTSemanticException::null.


3. Quit & restart eclipse.  Memory usage now ~48M.  Indexer not running.

4. Click Open Type.  Progress dialog "Updating Type Cache" appears for ~2
seconds and then the type selection dialog is displayed.  Memory usage now ~54MB.

5. Subsequent invocations are instantaneous.

Bogdan, can you investigate?  Seems like the indexer is doing something heavy. 
This same project had no trouble being indexed the last time I tried (maybe 2
weeks ago).
Comment 2 Bogdan Gheorghe CLA 2004-05-26 16:42:36 EDT
Hmmm...it sounds like we might be getting stuck on a couple of files and 
having the indexer timeout kick the parser along. 

Adding JohnC.
Comment 3 Bogdan Gheorghe CLA 2004-06-07 21:44:22 EDT
OK - I looked into this and I can reproduce what Dave is seeing: 

i) background type caching off
ii) import a project/let it index
iii) open types -> at this point memory shoots up to reach ~320MB (or throw an 
OutOfMemory error if the VM doesn't have enough memory assigned to it)

Looking at the code, if I comment out the last two lines of the insert 
function in TypeCache - where we add the new type to the collection and set 
the cache in the new type - there is no memory growth (ie. the indexer isn't 
significantly contributing to the memory growth).

Let me know if you need the project we've been seeing this behaviour on... 
(Also, maybe I can help out with the project that you saw the indexer getting 
stuck on - it's possible that there's a file in there that is hurting the 
parser...)






Comment 4 Andrew Niefer CLA 2004-06-10 14:04:25 EDT
I get an out of memory exception while building the type cache for the for a 
project containing GCC-3.3 on solaris.  The IEntryResult [] in 
IndexerTypesJob.updateTypes has 19874 elements, I made it to 6034 before 
getting the out of memory exception.

Indexing was completed and not running when we started building the type 
cache.  The size of the index on disk is 2.7 M
Comment 5 Alain Magloire CLA 2004-06-10 15:34:56 EDT
Chris is out on Vacation 'til Monday.
If this is urgent, let me know, I'll take a second look.

thanks.
Comment 6 David Daoust CLA 2004-06-10 15:44:44 EDT
Bogdan has set the default of the "calculate in background" flag to false by 
default (now that the user cannot see the flag).  This will get us (and any 
potential user) into a working state.  But, if anybody uses the navigate to 
type, on a project similar to andrews or mine, they will run out of memory 
(Quickly).

I don't see a need to fix it today or tomorrow, but I think that it should keep 
its P1 priority and be fixed before release.
Comment 7 Alain Magloire CLA 2004-06-10 16:06:35 EDT
> Bogdan has set the default of the "calculate in background" flag to false by 
> default (now that the user cannot see the flag).

hmm .. It should have been set to false by default since this was work in
progress.

Allright thanks for the heads up.
Comment 8 John Camelon CLA 2004-06-10 16:29:57 EDT
We (Doug, myself, Dave and Andrew) are working at making the parse as quick as 
possible.  If this becomes the case (if not for 2.0, for sure for 2.0.1) then 
Open-Type/Browser need not maintain a global table, perhaps just using a LRU 
cache for recent navigations.  

The fear from my standpoint is that once we start encountering 
OutOfMemoryErrors from enabling the browsing perspective, there is little the 
user can do about it as the cache gets rebuilt @ starting up anew.   
Comment 9 Alain Magloire CLA 2004-06-14 16:48:45 EDT
> Let me know if you need the project we've been seeing this behaviour

Can you attach the test case please.  Or if it's too big email.

thanks.
Comment 10 David Daoust CLA 2004-06-15 07:55:38 EDT
I have sent my project to Alain, Chris, Bogdan, and Andrew via private e-mail.
Comment 11 Chris Wiebe CLA 2004-06-18 14:10:32 EDT
I think we can consider this one fixed.