Monitoring SWT Graphics Resources with Sleak

Version 4.1.1 of Spoon and later now includes Sleak.  Sleak is a tool that monitors SWT graphics resources.  More information can be found at http://www.eclipse.org/articles/swt-design-2/sleak.htm.

To use Sleak pass the VM argument SLEAK when starting Spoon.  For example, in Linux modify the spoon.sh script and add -DSLEAK to the OPT variable:

OPT="$OPT -Xmx256m -Xms256m -XX:MaxPermSize=128m -DSLEAK -Djava.library.path=$LIBPATH . . . .

This is an example of using Sleak:

  1. Start Spoon with the SLEAK VM argument.
  2. Click the "Snap" button on the Sleak dialog.  A snapshot of allocated SWT resources is taken.
  3. Open a dialog is Spoon, such as the Repository Explorer. 
  4. Close the dialog. 
  5. Click the "Diff" button.  There should be no differences in allocated resources since the snapshot.