This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
The code in AttributeUtils.createComposite tries to create no instances if it isn't strictly necessary - returns the original instance if the passed array is empty and so on. But in case the passed array is longer, yet the resulting list has only one entry, it still produces AttributeUtils$Composite. This causes nontrivial overhead. For 1.3MB XSD file, I have found >200.000 instances of AttributeSet[] and as many AttributeUtils$Composite on heap, most of them representing exactly this case, which accounted for 5MB. Such instances were created this way: Short list from: [org.netbeans.api.editor.settings.AttributesUtilities$Immutable@17df2ba, null] java.lang.Exception: Stack trace org.netbeans.api.editor.settings.AttributesUtilities.createComposite(AttributesUtilities.java:134) org.netbeans.spi.editor.highlighting.support.OffsetsBag.merge(OffsetsBag.java:444) org.netbeans.spi.editor.highlighting.support.OffsetsBag.addHighlightImpl(OffsetsBag.java:428) org.netbeans.spi.editor.highlighting.support.OffsetsBag.addAllHighlightsImpl(OffsetsBag.java:521) org.netbeans.spi.editor.highlighting.support.OffsetsBag.addAllHighlights(OffsetsBag.java:143) org.netbeans.modules.editor.lib2.highlighting.CompoundHighlightsContainer.updateCache(CompoundHighlightsContainer.java:269) org.netbeans.modules.editor.lib2.highlighting.CompoundHighlightsContainer.getHighlights(CompoundHighlightsContainer.java:144) I'll attach a fix for this problem (5 megs back home...), but somebody should check the caller, null in the incomming array look suspicious...
Created attachment 40572 [details] Optimization of AttributeUtils
Silly me, thanks for the patch. OffsetsBag probably should not use AU.createComposite when merging highlights with 'empty' (non-highlighted) areas. I'll change it. Checking in AttributesUtilities.java; /cvs/editor/settings/src/org/netbeans/api/editor/settings/AttributesUtilities.java,v <-- AttributesUtilities.java new revision: 1.2; previous revision: 1.1 done
Checking in OffsetsBag.java; /cvs/editor/lib2/src/org/netbeans/spi/editor/highlighting/support/OffsetsBag.java,v <-- OffsetsBag.java new revision: 1.4; previous revision: 1.3 done Checking in PositionsBag.java; /cvs/editor/lib2/src/org/netbeans/spi/editor/highlighting/support/PositionsBag.java,v <-- PositionsBag.java new revision: 1.4; previous revision: 1.3 done