iOS: fix memory leak
This commit is contained in:
parent
37197a8f45
commit
e55b64158c
@ -33,7 +33,7 @@ - (void)getImageInfo:(NSDictionary *)resource withPromise:(DoricPromise *)promis
|
|||||||
@"height": @(image.size.height)
|
@"height": @(image.size.height)
|
||||||
}];
|
}];
|
||||||
}];
|
}];
|
||||||
[asyncResult setExceptionCallback:^(NSException * _Nonnull e) {
|
[asyncResult setExceptionCallback:^(NSException *_Nonnull e) {
|
||||||
DoricLog(@"Cannot load resource %s, %s", resource.description, e.description);
|
DoricLog(@"Cannot load resource %s, %s", resource.description, e.description);
|
||||||
}];
|
}];
|
||||||
} else {
|
} else {
|
||||||
@ -65,11 +65,10 @@ - (void)decodeToPixels:(NSDictionary *)resource withPromise:(DoricPromise *)prom
|
|||||||
CGColorSpaceRelease(colorspace);
|
CGColorSpaceRelease(colorspace);
|
||||||
CGContextRelease(context);
|
CGContextRelease(context);
|
||||||
|
|
||||||
NSData* data = [NSData dataWithBytes:(const void *)imageBytes length:sizeof(unsigned char) * iWidth * iHeight * iBytesPerPixel];
|
NSData *data = [NSData dataWithBytesNoCopy:(void *) imageBytes length:sizeof(unsigned char) * iWidth * iHeight * iBytesPerPixel freeWhenDone:YES];
|
||||||
|
|
||||||
[promise resolve:data];
|
[promise resolve:data];
|
||||||
}];
|
}];
|
||||||
[asyncResult setExceptionCallback:^(NSException * _Nonnull e) {
|
[asyncResult setExceptionCallback:^(NSException *_Nonnull e) {
|
||||||
DoricLog(@"Cannot load resource %s, %s", resource.description, e.description);
|
DoricLog(@"Cannot load resource %s, %s", resource.description, e.description);
|
||||||
}];
|
}];
|
||||||
} else {
|
} else {
|
||||||
|
@ -761,7 +761,7 @@ - (NSData *)getImagePixels {
|
|||||||
CGColorSpaceRelease(colorSpace);
|
CGColorSpaceRelease(colorSpace);
|
||||||
CGContextRelease(contextRef);
|
CGContextRelease(contextRef);
|
||||||
|
|
||||||
return [[NSData alloc] initWithBytesNoCopy:imageData length:width * height * bytesPerPixel];
|
return [[NSData alloc] initWithBytesNoCopy:imageData length:width * height * bytesPerPixel freeWhenDone:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc {
|
- (void)dealloc {
|
||||||
|
Reference in New Issue
Block a user