Példa

public class ClassA {

private Cursor cursor;

public void makeCursor( Device device, int i ) {

cursor = new Cursor( device, i );

if ( !cursor.isDisposed() ) {
//csináljon valamit...
}
}
}



Megoldás
Az erőforrás-szivárgások elkerülés érdekében győződjön meg róla, hogy a dispose() metódus minden org.eclipse.swt.graphics.Cursor objektumon meghívásra kerül.
Megjegyzés: Ez a szabály a Cursor konstruktor minden formájára vonatkozik.


public class ClassA {

private Cursor cursor;

public void makeCursor( Device device, int i ) {

cursor = new Cursor( device, i );

if ( !cursor.isDisposed() ) {
//csináljon valamit...
}
cursor.dispose();
}
}