dsto.dfc.swt.util
Class Sleak

java.lang.Object
  extended by dsto.dfc.swt.util.Sleak

public class Sleak
extends Object

Sleak is a simple tool that monitors SWT graphics resources. (Applications typically don't leak widget resources because of rule 2). You can use Sleak to detect leaks in SWT application code.

To use the tool, put the Sleak class on your class path and then find the place in your application code where you create the Display:

   Display display = new Display();
 
Before creating the display, create a DeviceData and set the data.tracking flag to true.
Then create the Display with this new DeviceData object.
Then create an instance of Sleak and open it.
Your new code will look something like this:

   DeviceData data = new DeviceData();
   data.tracking = true;
   Display display = new Display(data);
   Sleak sleak = new Sleak();
   sleak.open();
 

Now run your code as usual. When the Sleak window comes up, it looks like this:

When you press the "Start" button, Sleak collects and displays a list of the SWT graphics resources that are currently allocated. At this point, perform the action in your application that you suspect is leaking. When you press the "Stop" button, Sleak displays the list of resources that were allocated since you pressed "Start". Select a resource in the list on the left and it will be drawn in the canvas on the right. Select the "Stack" checkbox to see a stack trace showing where the resource was created. This does not necessarily imply that this resource was leaked - just that it currently exists. If you believe that this particular resource is no longer needed and should have been disposed, then you have discovered a leak. Adopted from the SWT site: http://www.eclipse.org/articles/swt-design-2/sleak.htm

Author:
weberd

Constructor Summary
Sleak()
           
Sleak(String title)
           
 
Method Summary
static void main(String[] args)
           
 void open()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Sleak

public Sleak()

Sleak

public Sleak(String title)
Method Detail

open

public void open()

main

public static void main(String[] args)


Copyright © 2008 Commonwealth of Australia