Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 352301

Summary: [performance] Intern strings used for creation of ICLanguageSettingsEntry objects
Product: [Tools] CDT Reporter: Andrew Gvozdev <angvoz.dev>
Component: cdt-coreAssignee: Andrew Gvozdev <angvoz.dev>
Status: RESOLVED FIXED QA Contact: Doug Schaefer <cdtdoug>
Severity: normal    
Priority: P3 CC: jamesblackburn+eclipse
Version: 8.0   
Target Milestone: 8.1.0   
Hardware: PC   
OS: All   
Whiteboard:
Bug Depends on: 205257    
Bug Blocks:    

Description Andrew Gvozdev CLA 2011-07-18 00:42:41 EDT
With bug 205257, strings of certain parts of project model were intern()-ed to improve memory footprint. In particular, OptionStringValue, PathInfo data. As those correspond to ICLanguageSettingsEntrys in ever "new" project model, and very much contain the same strings already - it makes sense to do the same for ACSettingEntry and CMacroEntry. I am testing that with new scanner discovery in Memory Analyser and getting 5x savings for retained heap for Firefox project.
Comment 1 Andrew Gvozdev CLA 2011-07-18 00:56:23 EDT
Committed on master.
Comment 2 Markus Schorn CLA 2011-07-18 02:52:05 EDT
Be careful with the measurements. Strings created with String.intern() are stored in the PermSpace which does not count towards the heap space.
Comment 3 James Blackburn CLA 2011-07-18 03:51:19 EDT
Agreed. This is going to quickly exhaust PermGen on Sun VMs, and will lead to confusing out of memory errors for users.

A better bet would be to implement the StringPool pattern used in the platform.  That way you get de-duplication, but the large memory footprint associated with the LSE strings is still contained in the normal Heap.
Comment 4 Andrew Gvozdev CLA 2011-07-18 09:15:13 EDT
My point here is that those same string values are *already* being interned in OptionStringValue, PathInfo and PerFileSICollector. If anything, this change avoids creating another copy on the heap.
BTW, do you guys know any good tool to analyze PermGen space?

(In reply to comment #3)
> A better bet would be to implement the StringPool pattern used in the platform.
> That way you get de-duplication, but the large memory footprint associated with
> the LSE strings is still contained in the normal Heap.
Thanks for the pointer, I'll take a look. Is it for strings only and do you know any pool pattern which can work with weak references?
Comment 5 Andrew Gvozdev CLA 2011-07-18 14:34:43 EDT
Markus, there is org.eclipse.cdt.internal.core.parser.util.WeakHashSet<T> class. It looks like the one I am looking for. Is there any ominous reason why you stopped using it, and why it is still there even if it doesn't appear to be used anywhere?