changeset 9815:92937f724bce

8041572: [macosx] huge native memory leak in AWTWindow.m Reviewed-by: serb, anthony
author pchelko
date Fri, 25 Apr 2014 16:27:30 +0400
parents 4c1180b2cbe7
children bec9dcd4c063
files src/macosx/native/sun/awt/AWTWindow.m src/macosx/native/sun/awt/CGraphicsDevice.m
diffstat 2 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/macosx/native/sun/awt/AWTWindow.m	Fri Jan 24 19:18:17 2014 +0100
+++ b/src/macosx/native/sun/awt/AWTWindow.m	Fri Apr 25 16:27:30 2014 +0400
@@ -261,7 +261,8 @@
 
 // returns id for the topmost window under mouse
 + (NSInteger) getTopmostWindowUnderMouseID {
-
+    NSInteger result = -1;
+    
     NSRect screenRect = [[NSScreen mainScreen] frame];
     NSPoint nsMouseLocation = [NSEvent mouseLocation];
     CGPoint cgMouseLocation = CGPointMake(nsMouseLocation.x, screenRect.size.height - nsMouseLocation.y);
@@ -274,11 +275,13 @@
             CGRect rect;
             CGRectMakeWithDictionaryRepresentation((CFDictionaryRef)[window objectForKey:(id)kCGWindowBounds], &rect);
             if (CGRectContainsPoint(rect, cgMouseLocation)) {
-                return [[window objectForKey:(id)kCGWindowNumber] integerValue];
+                result = [[window objectForKey:(id)kCGWindowNumber] integerValue];
+                break;
             }
         }
     }
-    return -1;
+    [windows release];
+    return result;
 }
 
 // checks that this window is under the mouse cursor and this point is not overlapped by others windows
--- a/src/macosx/native/sun/awt/CGraphicsDevice.m	Fri Jan 24 19:18:17 2014 +0100
+++ b/src/macosx/native/sun/awt/CGraphicsDevice.m	Fri Apr 25 16:27:30 2014 +0400
@@ -66,7 +66,8 @@
             CFArrayAppendValue(validModes, cRef);
         }
     }
-
+    CFRelease(allModes);
+    
     CGDisplayModeRef currentMode = CGDisplayCopyDisplayMode(displayID);
 
     BOOL containsCurrentMode = NO;
@@ -81,6 +82,7 @@
     if (!containsCurrentMode) {
         CFArrayAppendValue(validModes, currentMode);
     }
+    CGDisplayModeRelease(currentMode);
 
     return validModes;
 }