Community
Participate
Working Groups
Cloning for 3.6.2 and Carbon/Cocoa. Fix is the same on both platforms. +++ This bug was initially created as a clone of Bug #329499 +++ Build Identifier: org.eclipse.swt_3.6.1 When creating and resizing a Tracker on Mac OSX, a Cursor is leaked. package st.snippets; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.DeviceData; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Tracker; public class TrackerMouseDown2 { //Adapted from Snippet23.java //http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet23.java private static Point initialPoint = new Point(0, 0); private static boolean createResizableTracker = true; public static void main(String[] args) { DeviceData data = new DeviceData(); data.tracking = true; Display display = new Display(data); Sleak sleak = new Sleak(); sleak.open(); final Shell shell = new Shell(display); shell.open(); shell.addListener(SWT.MouseDown, new Listener() { public void handleEvent(Event e) { initialPoint = Display.getDefault().getCursorLocation(); if (createResizableTracker) { createResizableTracker(); } else { createStaticTracker(e); } } }); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); } private static void createStaticTracker(Event e) { final Tracker tracker = new Tracker(Display.getDefault(), SWT.NONE); tracker.setRectangles(new Rectangle[] { new Rectangle(e.x, e.y, 100, 100), }); System.out.println("Opening static tracker"); tracker.open(); } private static void createResizableTracker() { final Tracker tracker = new Tracker(Display.getDefault(), SWT.RESIZE); // tracker.setStippled(true); tracker.setRectangles(new Rectangle[] { new Rectangle(initialPoint.x, initialPoint.y, 1, 1) }); System.out.println("Opening resizable tracker"); tracker.open(); try { System.out.println("Would open edit snapshot shell here"); } catch (Throwable t) { t.printStackTrace(); } } Reproducible: Always Steps to Reproduce: See snippet above, which uses Sleak: http://www.eclipse.org/articles/swt-design-2/sleak.htm Start snippet to reveal canvas. "Snap" Sleak Click on canvas and drag the tracker. Repeat "Diff" Sleak For each tracker created there is a leaked NSCursor.
Created attachment 187996 [details] Patch for Carbon & Cocoa Same fix on Carbon and Cocoa for 3.6.2
NOTE: You must get PMC approval to fix any bug after RC2. Please fill out the following sections: - GOALS/BENEFITS: - RISKS: - PERFORMANCE IMPACTS:
(In reply to comment #2) > NOTE: You must get PMC approval to fix any bug after RC2. > > Please fill out the following sections: > - GOALS/BENEFITS: This fix was already applied to 3.7 HEAD and is working well there. It was specifically requested by a customer to address a significant resource leak in their product that won't move to 3.7 for some time. > - RISKS: Low to none. This change is already in platforms other than carbon and cocoa, and is known to be correct. > - PERFORMANCE IMPACTS: Reduced memory footprint due to Cursor resources being freed when they should be.
Fixed in R3_6_maintenance branch > 20110201 in both carbon and cocoa.