Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 254701 - Memory leak upon repeated calls of JEditorPane.setEditorKit() on a single pane
Memory leak upon repeated calls of JEditorPane.setEditorKit() on a single pane
Status: RESOLVED FIXED
Product: editor
Classification: Unclassified
Component: Painting & Printing
8.1
PC Linux
: P2 (vote)
: 8.1
Assigned To: apireviews
issues@editor
: API_REVIEW, API_REVIEW_FAST
Depends on:
Blocks: 239360
  Show dependency treegraph
 
Reported: 2015-08-25 11:27 UTC by Miloslav Metelka
Modified: 2015-09-03 01:25 UTC (History)
0 users

See Also:
Issue Type: DEFECT
:


Attachments
Fix of the problem that adds a ReleasableHighlightsContainer (22.91 KB, patch)
2015-08-31 13:25 UTC, Miloslav Metelka
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Miloslav Metelka 2015-08-25 11:27:23 UTC
Repeated changing of an editor kit over a single editor pane leads to memory leak of both NbEditorDocument and also DocumentView and accompanied view factories etc.

It can be reproduced by repeated invocations of search bar by Ctrl+F - each invocation goes through SearchComboBoxEditor.changeToOneLineEditorPane() calling
        editorPane.setEditorKit(kit);
at SearchComboBoxEditor:163

It used to manifest by unremoved FoldHierachyListener in FoldViewFactory but Svata fixed it by #246590 so now the reference is held by BracesMatchHighlighting. I will search for a way to possibly have an API/SPI for this.
Comment 1 Miloslav Metelka 2015-08-25 15:42:24 UTC
The HighlightsContainer should be notified about no longer being used (when HighlightingManager.rebuildAllLayers() is called and the original layers are thrown away. IMO we could create UnistallableHighlightsContainer interface to extend HighlightsContainer with "void uninstalled()" method in it.
Comment 2 Miloslav Metelka 2015-08-31 13:25:35 UTC
Created attachment 155774 [details]
Fix of the problem that adds a ReleasableHighlightsContainer

Fixing of the problem requires adding of ReleasableHighlightsContainer interface that any HighlightsContainer may implement to be notified once a HighlightingManager stops using the particular layer.
Comment 3 Miloslav Metelka 2015-08-31 13:27:38 UTC
Asking for fasttrack review since the ReleasableHighlightsContainer is added to Highlighting SPI.
Increased module's spec version and added apichanges item and a test.
Comment 4 Ralph Ruijs 2015-08-31 13:49:21 UTC
A quick query shows 41 implementations of HighlightsContainer, and 4 more in contrib.

R01 - Do they all need to implement the new ReleasableHighlightsContainer?
R02 - Should we log a warning for HighlightsContainers, not implementing ReleasableHighlightsContainer?
Comment 5 Miloslav Metelka 2015-09-01 08:13:04 UTC
Ralph, thank you for the comments.
> A quick query shows 41 implementations of HighlightsContainer, and 4 more in
> contrib.
> 
> R01 - Do they all need to implement the new ReleasableHighlightsContainer?
No, it's just an optional interface for the case when the particular highlights container wishes to be notified about releasing. If it does not implement it it just continues to work the same way as before.

> R02 - Should we log a warning for HighlightsContainers, not implementing
> ReleasableHighlightsContainer?
No, IMHO many highlights containers can work fine even without implementing it - they e.g. already use weak listeners etc. Unfortunately in the case of BracesMatchHighlighting it would not be sufficient (as soon as it register highlight into MasterMatcher the memory leak will happen) so I have implemented this approach.
Comment 6 Miloslav Metelka 2015-09-02 08:25:45 UTC
http://hg.netbeans.org/jet-main/rev/ea9c1e6864a7
Comment 7 Quality Engineering 2015-09-03 01:25:15 UTC
Integrated into 'main-silver', will be available in build *201509030002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/ea9c1e6864a7
User: Miloslav Metelka <mmetelka@netbeans.org>
Log: #254701 - Memory leak upon repeated calls of JEditorPane.setEditorKit() on a single pane.


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo