Your SlideShare is downloading. ×
Eclipsecon 2010 - Charles Souillard - BonitaSoft - No More Handles
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Eclipsecon 2010 - Charles Souillard - BonitaSoft - No More Handles

1,620
views

Published on

Published in: Technology

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,620
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

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