Community
Participate
Working Groups
Eclipse 3.3M5 For each realization of Window>Show View, Sleak is reporting 4 images leaked: java.lang.Error at org.eclipse.swt.graphics.Device.new_Object(Device.java:786) at org.eclipse.swt.graphics.Image.<init>(Image.java:491) at org.eclipse.jface.resource.ImageDescriptor.createImage(ImageDescriptor.java:289) at org.eclipse.jface.resource.ImageDescriptor.createResource(ImageDescriptor.java:165) at org.eclipse.jface.resource.DeviceResourceManager.allocate(DeviceResourceManager.java:56) at org.eclipse.jface.resource.AbstractResourceManager.create(AbstractResourceManager.java:88) at org.eclipse.jface.resource.LocalResourceManager.allocate(LocalResourceManager.java:82) at org.eclipse.jface.resource.AbstractResourceManager.create(AbstractResourceManager.java:88) at org.eclipse.jface.resource.ResourceManager.createImageWithDefault(ResourceManager.java:192) at org.eclipse.jface.action.ActionContributionItem.updateImages(ActionContributionItem.java:1033) at org.eclipse.jface.action.ActionContributionItem.update(ActionContributionItem.java:858) at org.eclipse.jface.action.ActionContributionItem.fill(ActionContributionItem.java:281) at org.eclipse.ui.internal.ShowViewMenu.fill(ShowViewMenu.java:265) at org.eclipse.jface.action.MenuManager.update(MenuManager.java:665) at org.eclipse.jface.action.MenuManager.handleAboutToShow(MenuManager.java:395) at org.eclipse.jface.action.MenuManager.access$1(MenuManager.java:390) at org.eclipse.jface.action.MenuManager$2.menuShown(MenuManager.java:416) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:222) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:962) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:943) at org.eclipse.swt.widgets.Control.WM_INITMENUPOPUP(Control.java:3783) at org.eclipse.swt.widgets.Control.windowProc(Control.java:3500) at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1554) at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:1752) at org.eclipse.swt.widgets.Display.windowProc(Display.java:4172) at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method) at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2195) at org.eclipse.swt.widgets.Shell.callWindowProc(Shell.java:456) at org.eclipse.swt.widgets.Control.windowProc(Control.java:3562) at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1554) at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:1752) at org.eclipse.swt.widgets.Display.windowProc(Display.java:4159) at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method) at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2195) at org.eclipse.swt.widgets.Shell.callWindowProc(Shell.java:456) at org.eclipse.swt.widgets.Control.windowProc(Control.java:3562) at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1554) at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:1752) at org.eclipse.swt.widgets.Display.windowProc(Display.java:4159) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2200) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3102) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2264) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2228) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2103) at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:457) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:452) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:101) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:146) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:169) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:476) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:416) at org.eclipse.equinox.launcher.Main.run(Main.java:1124) at org.eclipse.equinox.launcher.Main.main(Main.java:1099)
This isn't a leak - it is caching. Here is what is happening. ActionContributionItem has a LocalResourceManager for each instance (which is each entry in the menu) which is backed on the JFace ResourceManager. When the menu is created the images are created using these local resource managers. As they are backed by the JFace resource manager only those images for views that are not currently open will be allocated. These images are still in the local resource managers until the contribution item is updated. Contribution items will throw out thier old ResourceManagers and replace them with new ones when they refresh. You can see this by opening the same Show View menu twice. On the first open you will see n - m new images where n = menu size and m = number of open views. If you re-open you will see the same number although the images will be different instances (as they have new managers). We create new managers so as not to cache obsolete images. This way we do not cache any images that are not shown to the user when the menu changes. If we used the JFace resource manager directly they would remain in the cache for the life of the application.
You can verify this by opening every view in the show view menu and then trying again - there will be no new images.
Thanks for the investigation.