changeset 9986:415e14c14558

8036917: [macosx] Native memory leaks. Reviewed-by: serb, azvegint
author pchelko
date Thu, 08 May 2014 16:50:42 +0400
parents 6f660f46f0f2
children 9c6ff56dfe00
files src/macosx/native/sun/awt/CImage.m
diffstat 1 files changed, 16 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/macosx/native/sun/awt/CImage.m	Thu May 08 11:46:03 2014 +0200
+++ b/src/macosx/native/sun/awt/CImage.m	Thu May 08 16:50:42 2014 +0400
@@ -76,17 +76,17 @@
 
 static NSBitmapImageRep* CImage_CreateImageRep(JNIEnv *env, jintArray buffer, jint width, jint height)
 {
-    NSBitmapImageRep* imageRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
-                                                                         pixelsWide:width
-                                                                         pixelsHigh:height
-                                                                      bitsPerSample:8
-                                                                    samplesPerPixel:4
-                                                                           hasAlpha:YES
-                                                                           isPlanar:NO
-                                                                     colorSpaceName:NSDeviceRGBColorSpace
-                                                                       bitmapFormat:NSAlphaFirstBitmapFormat
-                                                                        bytesPerRow:width*4 // TODO: use explicit scanStride
-                                                                       bitsPerPixel:32];
+    NSBitmapImageRep* imageRep = [[[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
+                                                                          pixelsWide:width
+                                                                          pixelsHigh:height
+                                                                       bitsPerSample:8
+                                                                     samplesPerPixel:4
+                                                                            hasAlpha:YES
+                                                                            isPlanar:NO
+                                                                      colorSpaceName:NSDeviceRGBColorSpace
+                                                                        bitmapFormat:NSAlphaFirstBitmapFormat
+                                                                         bytesPerRow:width*4 // TODO: use explicit scanStride
+                                                                        bitsPerPixel:32] autorelease];
 
     jint *imgData = (jint *)[imageRep bitmapData];
     if (imgData == NULL) return 0L;
@@ -115,9 +115,8 @@
     
     NSBitmapImageRep* imageRep = CImage_CreateImageRep(env, buffer, width, height);
     if (imageRep) {
-        NSImage *nsImage = [[[NSImage alloc] initWithSize:NSMakeSize(width, height)] retain];
+        NSImage *nsImage = [[NSImage alloc] initWithSize:NSMakeSize(width, height)];
         [nsImage addRepresentation:imageRep];
-        [imageRep release];
         result = ptr_to_jlong(nsImage);
     }
 
@@ -160,7 +159,7 @@
         (*env)->ReleaseIntArrayElements(env, widths, ws, JNI_ABORT);
     }
     if ([reps count]) {
-        NSImage *nsImage = [[[NSImage alloc] initWithSize:NSMakeSize(0, 0)] retain];
+        NSImage *nsImage = [[NSImage alloc] initWithSize:NSMakeSize(0, 0)];
         [nsImage addRepresentations: reps];
         result = ptr_to_jlong(nsImage);
     }
@@ -184,7 +183,7 @@
 
     IconRef iconRef;
     if (noErr == GetIconRef(kOnSystemDisk, kSystemIconsCreator, selector, &iconRef)) {
-        image = [[[NSImage alloc] initWithIconRef:iconRef] retain];
+        image = [[NSImage alloc] initWithIconRef:iconRef];
         ReleaseIconRef(iconRef);
     }
 
@@ -206,7 +205,7 @@
 JNF_COCOA_ENTER(env);
 
     NSString *path = JNFNormalizedNSStringForPath(env, file);
-    image = [[[NSImage alloc] initByReferencingFile:path] retain];
+    image = [[NSImage alloc] initByReferencingFile:path];
 
 JNF_COCOA_EXIT(env);
 
@@ -435,7 +434,7 @@
 
     JNF_COCOA_ENTER(env);
 
-    NSBitmapImageRep* imageRep = [CImage_CreateImageRep(env, buffer, width, height) autorelease];
+    NSBitmapImageRep* imageRep = CImage_CreateImageRep(env, buffer, width, height);
     if (imageRep) {
         NSData *tiffImage = [imageRep TIFFRepresentation];
         jsize tiffSize = (jsize)[tiffImage length];