在这方面遇到了困难,希望有人能提供帮助!刚开始发帖,但发现这是我的首选网站,可以帮助我完成我的应用程序。
我有一个应用程序,它采用 CGImage 并使用 writeImageToSavedPhotosAlbum:orientation:completionBlock: 将其复制到照片库。功能上效果很好,但 Instruments 似乎告诉我我有泄漏。通过反复试验和代码注释,我发现这个特定的行导致了泄漏:
[library writeImageToSavedPhotosAlbum:myCGImage
orientation:assetOrientation
completionBlock:^(NSURL *assetURL, NSError *error){
NSLog(@"image copied to album");
}];
那条线对我来说似乎无害,所以我真的不确定它为什么会导致问题。注释掉,没有泄漏。把它留在里面,我看到一个泄漏!
以下是 Instrument 在 Leaked Blocks 中显示的内容:
Leaked Object # Address Size Responsible Library Responsible Frame
GeneralBlock-36864, 0x8c77000 36.00 KB MusicLibrary MemNewPtrClear
这是 Instruments 的堆栈跟踪,这似乎暗示它确实与照片库有关:
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
我稍后会发布myCGIImage和库,assetOrientation 只是一个 ALAssetOrientation。没有其他东西是自定义代码,所以我很难过!(如果这可能导致问题,我很乐意发布我的其他代码行)。
非常感谢任何帮助!!!