Been having a tough time on this one, hope someone can help! New to posting, but have found this to be my go-to site for helping me through my apps.
I have an app that takes a CGImage and copies it to the Photo Library using writeImageToSavedPhotosAlbum:orientation:completionBlock:. Functionally works great, but Instruments seems to be telling me I have a leak. Through trial and error and commenting of code, I've found that this particular line is causing the leak:
[library writeImageToSavedPhotosAlbum:myCGImage
orientation:assetOrientation
completionBlock:^(NSURL *assetURL, NSError *error){
NSLog(@"image copied to album");
}];
That line seems innocuous enough to me, so I'm really not sure why it's causing a problem. Commented out, no leak. Leave it in, I see a leak!
Here's what Instrument shows in Leaked Blocks:
Leaked Object # Address Size Responsible Library Responsible Frame
GeneralBlock-36864, 0x8c77000 36.00 KB MusicLibrary MemNewPtrClear
Here's the stack trace from Instruments, which seems to imply it's related to the photo library indeed:
0 libsystem_c.dylib calloc
1 MusicLibrary MemNewPtrClear
2 MusicLibrary ReadITImageDB
3 MusicLibrary -[MLPhotoLibrary _loadImageLibrary]
4 MusicLibrary -[MLPhotoLibrary albums]
5 PhotoLibrary -[PLPhotoLibrary albums]
6 PhotoLibrary -[PLPhotoLibrary eventAlbumContainingPhoto:]
7 PhotoLibrary -[PLPhotoLibrary pictureWasTakenOrChanged]
8 PhotoLibrary __-[PLAssetsSaver queueJobData:requestEnqueuedBlock:completionBlock:imagePort:previewImagePort:]_block_invoke_2
9 libdispatch.dylib _dispatch_call_block_and_release
10 libdispatch.dylib _dispatch_main_queue_callback_4CF$VARIANT$up
11 CoreFoundation __CFRunLoopRun
12 CoreFoundation CFRunLoopRunSpecific
13 CoreFoundation CFRunLoopRunInMode
14 GraphicsServices GSEventRunModal
15 GraphicsServices GSEventRun
16 UIKit -[UIApplication _run]
17 UIKit UIApplicationMain
18 mogofoto main /Users/Jutsu/Documents/mogofoto2/main.m:14
19 mogofoto start
I do release myCGIImage later, and library as well, and assetOrientation is simply a ALAssetOrientation. Nothing else is custom code, so I'm stumped! (I'd be happy to post my other lines of code surrounding this if that may cause the problem).
Any help is hugely appreciated!!!