Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SWT No More Handles

Windows XP has the limit 10000 user handles for each process and total 32000 for each desktop session. However, when I run 4 or 5 SWT process, each consuming no more than 2000 user handles, the SWT No More handles exception will always be threw.

Does anyone know why?

like image 598
James Avatar asked Jan 07 '10 06:01

James


3 Answers

If I understand you correctly, you are probably getting the following exception:

org.eclipse.swt.SWTError: No more handles

You may be creating resources (such as Font, Image or GC objects) that you aren't correctly disposing. You might want to take a moment to read through the SWT guide on Managing Operating System Resources.

To determine if this is indeed the case, I can recommend this useful article: Diagnosing Handle Leaks in SWT/RCP Windows Applications, which explains what resources are and suggests using Process Explorer or DPus to locate leaks.

A colleague also highly recommends Sleak, a SWT-focused application that can actually inform you which resources are remaining in residual memory.

For a very technical understanding of what handles SWT is making, this Sybase article describes that there are three kinds: User Object, GDI Object or Kernel Object handles, each of which has its own maximum.

like image 150
Paul Lammertsma Avatar answered Oct 27 '22 11:10

Paul Lammertsma


You have some sort of resource leak in your program most likely. Use the following utility (http://www.eclipse.org/articles/swt-design-2/sleak.htm) as an easy way to find swt resource leaks. I used it to clean up a whole slew of problems in an rcp app I was working on

like image 44
fisherja Avatar answered Oct 27 '22 12:10

fisherja


The limit isn't 10000 handles. Applications can use far more than 10000 handles (if RAM allows). The limit is on GDI and User resources (graphical elements).

What kind of resources are the SWT applications using (you can see this with taskmgr)? That would help to understand what is leaking.

like image 2
ReinstateMonica Larry Osterman Avatar answered Oct 27 '22 12:10

ReinstateMonica Larry Osterman