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.

Bug 183004 - Memory leak in Kenai UI
Summary: Memory leak in Kenai UI
Status: RESOLVED FIXED
Alias: None
Product: connecteddeveloper
Classification: Unclassified
Component: Team Framework (show other bugs)
Version: 6.x
Hardware: Macintosh Mac OS X
: P3 normal (vote)
Assignee: _ tboudreau
URL:
Keywords: PERFORMANCE
Depends on:
Blocks:
 
Reported: 2010-03-28 02:15 UTC by _ tboudreau
Modified: 2010-04-02 05:02 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description _ tboudreau 2010-03-28 02:15:21 UTC
Got an OOME (not surprising itself, as I was attempting to open all projects in nbsrc).  Analyzing the heap dump (47.1Mb bzip2 -9'd, so probably too big for upload, but I'll try), the result is curious:

The largest memory consumer is 225 instances of javax.swing.CellRendererPane, referenced through org.netbeans.kenai.ui.treelist.RendererPanel, retaining 27351205 bytes of memory.

javax.swing.CellRendererPane - parent
 org.netbeans.kenai.ui.treelist.RendererPanel - parent
  javax.swing.JPanel - parent
   org.netbeans.kenai.ui.treelist.TreeNodeList$ProgressLabel
    Ljava.lang.Object
     javax.swing.event.EventListenerList
      javax.swing.Timer - flasher
       javax.swing.TimerQueue
       org.openide.editor.ExtCaret
        org.openide.text.QuietEditorPane

This looks suspicious for several reasons:  CellRendererPane is a throwaway component - there shouldn't be any reason to keep them around - unless there are 225 JTrees in the UI, there is no reason there should be so many existing.

Right now my IDE is hobbling through trying to scan way too many projects, so I can't get at the source to see what it does, but it looks like a timer is left running (possibly because the component is left inside a CellRendererPane, which fools components into thinking they're on-screen - so this could be caused by the caret blink timer of a JTextComponent).
Comment 1 _ tboudreau 2010-03-28 03:39:15 UTC
Relatively simple problem - TreeListNode.ProgressLabel starts a timer, but never stops it unless something explicitly calls setVisible(false) - so it can be held forever (and will hold a reference to its parent node) forever.  Since it is a cell renderer, starting/stopping based on addNotify()/removeNotify() is not possible.

Changed the following:
 - ProgressLayer is now a static class w/ a weak reference to the node
 - Made the class public (within the module), added a stop() method, and call it from cases where it was never being stopped
 - If the node becomes unreferenced, the next timer tick will notice and stop the timer (note that the Node may still exist long after the progress label is not in use, and the timer will still be running unless stop() is called - this just gives it a chance of eventually being garbage collected)

Fixed in main/ ec51b1fe3f2d
Comment 2 Quality Engineering 2010-04-02 05:02:44 UTC
Integrated into 'main-golden', will be available in build *201004020200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/ec51b1fe3f2d
User: tboudreau@netbeans.org
Log: #183004 - memory leak in kenai ui due to a never-stopped timer on an inner class that holds a reference to the outer class