Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 373298

Summary: Possible Resource leaks in Graphiti
Product: [Modeling] Graphiti Reporter: Patrick Talbot <ptalbot>
Component: CoreAssignee: Project Inbox <graphiti-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: matthias.gorning, michael.wenz
Version: 0.8.0Flags: michael.wenz: juno+
Target Milestone: 0.9.0   
Hardware: All   
OS: All   
Whiteboard: Juno M7 Theme_bugs

Description Patrick Talbot CLA 2012-03-05 18:48:46 EST
Build Identifier: 0.8.2 and 0.9.0

I'm experiencing some SWT related error when working with a big diagram in Graphiti.
 
The stack trace is as below:
!ENTRY org.eclipse.ui 4 0 2012-03-02 18:17:25.903
 !MESSAGE Unhandled event loop exception
 !STACK 0
 org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTError: No more handles)
 at org.eclipse.swt.SWT.error(SWT.java:4083)
 at org.eclipse.swt.SWT.error(SWT.java:3998)
 at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:137)
 at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4041)
 at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3660)
 at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
 at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
 at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
 at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
 at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
 at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
 at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
 at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
 at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
 at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
 at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
 at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
 at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:620)
 at org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)
 at org.eclipse.equinox.launcher.Main.run(Main.java:1408)
 Caused by: org.eclipse.swt.SWTError: No more handles
 at org.eclipse.swt.SWT.error(SWT.java:4109)
 at org.eclipse.swt.SWT.error(SWT.java:3998)
 at org.eclipse.swt.SWT.error(SWT.java:3969)
 at org.eclipse.swt.widgets.Control.internal_new_GC(Control.java:1550)
 at org.eclipse.swt.graphics.GC.<init>(GC.java:166)
 at org.eclipse.draw2d.BufferedGraphicsSource.getGraphics(BufferedGraphicsSource.java:104)
 at org.eclipse.draw2d.DeferredUpdateManager.getGraphics(DeferredUpdateManager.java:147)
 at org.eclipse.draw2d.DeferredUpdateManager.repairDamage(DeferredUpdateManager.java:310)
 at org.eclipse.draw2d.DeferredUpdateManager.performUpdate(DeferredUpdateManager.java:192)
 at org.eclipse.draw2d.DeferredUpdateManager$UpdateRequest.run(DeferredUpdateManager.java:44)
 at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
 at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
 ... 22 more
 

It seems that this is usually related to Native resources not properly disposed in SWT, especially with Images and Fonts.

Could you have a look at all resource usage in Graphiti and see if all instantiated resources are properly disposed?

Thanks in advance.

Reproducible: Sometimes

Steps to Reproduce:
Will happen after a while on big diagrams.
Comment 1 Michael Wenz CLA 2012-03-06 03:47:04 EST
I did a quick reference check for the constructors of SWT Font and found 
2 ambigious usages in Tooltip and DataTypeTransformation. Needs a closer look.
Comment 2 Michael Wenz CLA 2012-04-11 09:29:50 EDT
I checked the usages of SWT Font and Image within the Graphiti framework and indeed found 2 issues with not released handles:
- An image was not released in the SVG export (this is minor and should not cause this issue)
- Fonts used for the tooltips on the context button pads were not released again when the pad disappeared. This could cause the issues you noticed when working on large diagrams
GDIView showed an increase in the font handles before the fix, now the numbers are constant after a startup phase.

Changes are checked-in and pushed to head for Graphiti 0.9.0:
commit 4a76009ff9dfbb4b33a4526e81f0078841c49356
Author: mwenz <michael.wenz@sap.com> 2012-04-11 14:48:47
Committer: mwenz <michael.wenz@sap.com> 2012-04-11 15:20:16
Parent: 4203e4eab7fae63b217175bffb4866c7012ea660 (Bug 373298 - Fixed font resource leak with context button pad tooltip fonts)
Branches: origin/master, master

commit 4203e4eab7fae63b217175bffb4866c7012ea660
Author: mwenz <michael.wenz@sap.com> 2012-04-11 14:04:30
Committer: mwenz <michael.wenz@sap.com> 2012-04-11 15:20:15
Parent: 41bf531bd9869c3f175e29db96155035fa498a1e (Bug 368124 - ConnectionDecorator with Text causes problems)
Child: 4a76009ff9dfbb4b33a4526e81f0078841c49356 (Bug 373298 - Fixed image resource leak in SVG export and cleaned up around unused image creation without dispose)
Branches: origin/master, master
Comment 3 Patrick Talbot CLA 2012-04-11 09:37:21 EDT
That's great news! I had found some images not properly disposed in my own code as well but I'm glad you've been able to fix any leak in the framework as well.

Thanks for the hard work!
Comment 4 Michael Wenz CLA 2012-06-29 04:22:52 EDT
Part of Graphiti 0.9.0 (Eclipse Juno)