As Baz mentioned, the maximum number of GDI handles, which is specific to Windows, influences how many resources a (SWT) process can allocate. See the this question for more details. On other platforms, the limit may be different.
As you already found out, SWT Sleak is the right tool to monitor graphics resource usage of SWT applications.
If an application runs out of handles, it does not just 'crash'. An SWTError
is raised when the limit is reached and an attempt is made to create a new resource.
In general, the exception can be handled like any other exception and after releasing unused resources, new ones can be created.
IIRC, the default exception handler of RCP applications will open a dialog that asks the user to exit the application gracefully in this case.
However, running out of handles in an SWT application is usually a sign that your strategy of how widgets are created/used is wrong.
A common strategy to reduce the number of resources is to use lazy/virtual Tree
s and Table
s and to create widgets only when they become visible and dispose of them when no longer needed. In a TabFolder
, for example, you would defer populating the TabItem
unless it gets selected.