Community
Participate
Working Groups
I did some profiling of my RCP app and I found a memory leak in FormImages#markFinished method. Here's the code in question: public synchronized boolean markFinished(Image image, Display display) { checkHashMaps(); AbstractImageDescriptor desc = (AbstractImageDescriptor)descriptors.get(image); if (desc != null) { LocalResourceManager resourceManager = manager.getResourceManager(display); resourceManager.destroyImage(desc); if (resourceManager.find(desc) == null) { descriptors.remove(image); validateHashMaps(); } return true; } // if the image was not found, dispose of it for the caller image.dispose(); return false; } The problem is with this line: descriptors.remove(image); This line does not actually remove the entry from the descriptors HashMap. This is because the hashCode of the Image object changes (it becomes 0) when the image is disposed and the Image is always disposed in this line. This means that image descriptors area slowly leaked and the descriptors HashMap grows in size. I guess the good thing is that the Image resource is disposed so no graphical resources are leaked, but there is a memory leak nonetheless. A possible solution to this problem is to use "new Integer(image.hashCode())" as keys in descriptors map. Then the key could be constructed before calling resourceManager.destroyImage(desc) method so that we obtain the hashCode before the image is disposed.
https://git.eclipse.org/r/#/c/42077/
Gerrit change https://git.eclipse.org/r/42077 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=a7dfb2d0456645ce9c1e262043c38bfb8853213b
Thanks Tomasz!