2013-02-05 68 views
2
NSDictionary* result = nil; 

CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)[self TIFFRepresentation], NULL); 

if (NULL == source) 
{ 
} 
else 
{ 
    CFDictionaryRef metadataRef = CGImageSourceCopyPropertiesAtIndex (source, 0, NULL); 
    if (metadataRef) 
    { 
     NSDictionary* immutableMetadata = (__bridge NSDictionary *)metadataRef; 
     if (immutableMetadata) 
     { 
      result = [NSDictionary dictionaryWithDictionary : (__bridge NSDictionary *)metadataRef]; 
     } 

     CFRelease(metadataRef); 
     metadataRef = nil; 
    } 

    CFRelease(source); 
    source = nil; 
} 

return result; 

我正在使用XCode和ARC。 此代碼會導致我的應用程序泄漏內存,當我在循環中的許多圖像上運行它時。 有人知道我做錯了什麼嗎?CGImageSourceRef memoryleak

回答

1

圍繞代碼包裝@autoreleasepool解決了問題。圖像大約1.2MB

相關問題