Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
No more “No more handles”<br />March 24, 10<br />Charles SouillardCTO and co-founder of BonitaSoft<br />Charles Souillard ...
March 24, 10<br />Charles Souillard – CTO and co-founder<br />www.bonitasoft.com | © BonitaSoft S.A.<br />1<br />Tech Talk...
March 24, 10<br />Charles Souillard – CTO and co-founder<br />www.bonitasoft.com | © BonitaSoft S.A.<br />2<br />Whatis a ...
Threads
Graphics (images, colors, fonts)</li></ul>A handlecontains:<br /><ul><li>The resourceaddress
The resourcetype</li></li></ul><li>March 24, 10<br />Charles Souillard – CTO and co-founder<br />www.bonitasoft.com | © Bo...
March 24, 10<br />Charles Souillard – CTO and co-founder<br />www.bonitasoft.com | © BonitaSoft S.A.<br />4<br />« No more...
If a handle is available, access the resource
If there are no more handles available, SWT will throw “no more handles”</li></ul>Memory taken for handles increases drama...
March 24, 10<br />Charles Souillard – CTO and co-founder<br />www.bonitasoft.com | © BonitaSoft S.A.<br />5<br />Best prac...
not safe: if an exception is thrown before disposal</li></li></ul><li>March 24, 10<br />Charles Souillard – CTO and co-fou...
S-Leak is a simple tool that monitors SWT graphics resources</li></ul>Intercept SWT creation/disposal<br />Update site<br ...
March 24, 10<br />Charles Souillard – CTO and co-founder<br />www.bonitasoft.com | © BonitaSoft S.A.<br />8<br />UsingS-Le...
Upcoming SlideShare
Loading in …5
×

Eclipsecon 2010 - Charles Souillard - BonitaSoft - No More Handles

2,075 views

Published on

Published in: Technology
  • Be the first to comment

Eclipsecon 2010 - Charles Souillard - BonitaSoft - No More Handles

  1. 1. No more “No more handles”<br />March 24, 10<br />Charles SouillardCTO and co-founder of BonitaSoft<br />Charles Souillard – CTO and co-founder<br />www.bonitasoft.com | © BonitaSoft S.A.<br />
  2. 2. March 24, 10<br />Charles Souillard – CTO and co-founder<br />www.bonitasoft.com | © BonitaSoft S.A.<br />1<br />Tech TalkOverview<br />Whatis a « handle »?<br />The « no more handles » error<br />Best practices<br />Whatyoushould know<br />Tracking the number of handles<br />
  3. 3. March 24, 10<br />Charles Souillard – CTO and co-founder<br />www.bonitasoft.com | © BonitaSoft S.A.<br />2<br />Whatis a handle?<br />Mandatorystepto access a system resource, for example:<br /><ul><li>Files
  4. 4. Threads
  5. 5. Graphics (images, colors, fonts)</li></ul>A handlecontains:<br /><ul><li>The resourceaddress
  6. 6. The resourcetype</li></li></ul><li>March 24, 10<br />Charles Souillard – CTO and co-founder<br />www.bonitasoft.com | © BonitaSoft S.A.<br />3<br />« No more handles » error<br />
  7. 7. March 24, 10<br />Charles Souillard – CTO and co-founder<br />www.bonitasoft.com | © BonitaSoft S.A.<br />4<br />« No more handles » error<br />The more objects a diagram contains, the sooner the error is thrown<br />This error shows up when<br /><ul><li>New Image(…) -> System.getHandle()
  8. 8. If a handle is available, access the resource
  9. 9. If there are no more handles available, SWT will throw “no more handles”</li></ul>Memory taken for handles increases dramatically on all OS<br />Easy to reproduce on Windows (limited pool)<br />
  10. 10. March 24, 10<br />Charles Souillard – CTO and co-founder<br />www.bonitasoft.com | © BonitaSoft S.A.<br />5<br />Best practices<br />Treat handles much like Java Streams<br />Rule 1: If you created it, you dispose of it (because the GC can’t!)<br />Rule 2: Dispose of the parent – this also disposes of the children<br />Rule 3: Allocate resources in activate() and dispose them in deactivate()<br />Rule 4: Use resources from registries as much as possible; no need to (don’t!) dispose of them:<br /><ul><li>AbstractUIPlugin, JFaceResources, ColorConstants</li></li></ul><li>March 24, 10<br />Charles Souillard – CTO and co-founder<br />www.bonitasoft.com | © BonitaSoft S.A.<br />6<br />Whatyoushouldknow...<br />It IS necessary to dispose of used handles as they consume a lot of memory<br />The GC does NOT reclaim handles<br />Disposing of handles in Object.finalize() does NOT work<br /><ul><li>nondeterministic: an object could be marked to be collected but not released immediately
  11. 11. not safe: if an exception is thrown before disposal</li></li></ul><li>March 24, 10<br />Charles Souillard – CTO and co-founder<br />www.bonitasoft.com | © BonitaSoft S.A.<br />7<br />UsingS-Leak to trackhandles<br />S-Leak<br /><ul><li>www.eclipse.org/swt/tools.php
  12. 12. S-Leak is a simple tool that monitors SWT graphics resources</li></ul>Intercept SWT creation/disposal<br />Update site<br /><ul><li> www.eclipse.org/swt/updates/3.5</li></ul>Add S-Leak view to your Perspectivelayout.addStandaloneView: “org.eclipse.swt.tools.views.SleakView”<br />
  13. 13. March 24, 10<br />Charles Souillard – CTO and co-founder<br />www.bonitasoft.com | © BonitaSoft S.A.<br />8<br />UsingS-Leak to trackhandles<br />Setup launch configuration<br />Add the org.eclipse.swt.toolsplugin and its dependencies<br />Enable tracing options:<br /><ul><li>org.eclipse.ui/debug
  14. 14. org.eclipse.ui/trace/graphics</li></li></ul><li>March 24, 10<br />Charles Souillard – CTO and co-founder<br />www.bonitasoft.com | © BonitaSoft S.A.<br />9<br />UsingS-Leak to trackhandles<br />Launch your RCP Application<br />Snap to have a base for comparison <br />Diff to see new handles since the previous Snap <br />Show stackTrace to retrieve where the resource has been created<br />
  15. 15. March 24, 10<br />UsingS-Leak to trackhandles<br />Charles Souillard – CTO and co-founder<br />www.bonitasoft.com | © BonitaSoft S.A.<br />10<br />
  16. 16. March 24, 10<br />Charles Souillard – CTO and co-founder<br />www.bonitasoft.com | © BonitaSoft S.A.<br />11<br />Other tips tohandlehandles<br />Use Task Manager -> GDI objects in Windows to know how many handles have been used<br />In Windows, handles are limited<br /><ul><li>10,000 / application
  17. 17. 65,536 / user session
  18. 18. BUT this can be changed in the registry (<65,536)</li></li></ul><li>March 24, 10<br />Charles Souillard – CTO and co-founder<br />www.bonitasoft.com | © BonitaSoft S.A.<br />12<br />~ 20 words about BonitaSoft<br />LeadingBonita Open Solution (BOS) development<br />BOS 5.1 releasednextweek<br />650+ active members<br />250,000 downloads<br />Meet us at the Poster session for a S-Leakdemo and at the unconference for a BOS demo!<br />http://www.bonitasoft.org<br />

×