Search code examples
eclipsememory-leaksrcp

Memory leak in Eclipse RCP applications


How can the memory leak in Eclipse RCP applications detected?


Solution

  • You might want try the Memory Leak Detector that comes with JRockit Mission Control together with Eclipse MAT. It's a powerful combination. Both tools are free to use for development.

    With JRockit Mission Control you can inspect the heap online and see the exact number objects of a certain type that are live, without the need to take time consuming snapshots. You can directly see if you got an an Editor, View or listener object left on the heap after you closed the View/Editor. It's usually a framework listener that holds on to your view/editor. Remember, you must go to Windows->Preferences->Memory Leak Detector->Trend and set Lowest Heap Usage to report to 0.0 to se all object instances.

    alt text
    (source: oracle.com)

    With MAT you can then use the shortest path to thread root to find the chain that is holding on to the leaking object. See below

    alt text http://dev.eclipse.org/blogs/memoryanalyzer/files/2008/04/path2gc_all.png

    Modify your code and verify with the Memory Leak Detector that the object is garbage collected when you close the editor/view.