Skip to content

Commit 7e4f7ca

Browse files
committed
Fix memory leak on capture image
1 parent 80af830 commit 7e4f7ca

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

LLSimpleCamera/LLSimpleCamera.m

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ -(void)capture:(void (^)(LLSimpleCamera *camera, UIImage *image, NSDictionary *m
319319
// freeze the screen
320320
[self.captureVideoPreviewLayer.connection setEnabled:NO];
321321

322+
__weak typeof(self) _self = self;
322323
[self.stillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler: ^(CMSampleBufferRef imageSampleBuffer, NSError *error) {
323324

324325
UIImage *image = nil;
@@ -335,18 +336,18 @@ -(void)capture:(void (^)(LLSimpleCamera *camera, UIImage *image, NSDictionary *m
335336
image = [[UIImage alloc] initWithData:imageData];
336337

337338
if(exactSeenImage) {
338-
image = [self cropImageUsingPreviewBounds:image];
339+
image = [_self cropImageUsingPreviewBounds:image];
339340
}
340341

341-
if(self.fixOrientationAfterCapture) {
342+
if(_self.fixOrientationAfterCapture) {
342343
image = [image fixOrientation];
343344
}
344345
}
345346

346347
// trigger the block
347348
if(onCapture) {
348349
dispatch_async(dispatch_get_main_queue(), ^{
349-
onCapture(self, image, metadata, error);
350+
onCapture(_self, image, metadata, error);
350351
});
351352
}
352353
}];

0 commit comments

Comments
 (0)