开发者

Nasty NSPropertyListSerialization Leak

开发者 https://www.devze.com 2023-02-04 22:14 出处:网络
NSString *anError = nil; id plist; plist = [NSPropertyListSerialization propertyListFromData:rawCourseArray mutabilityOption:NSPropertyListImmutable format:&format errorDescription:&a开发者_
NSString *anError = nil;
 id plist;
 plist = [NSPropertyListSerialization propertyListFromData:rawCourseArray mutabilityOption:NSPropertyListImmutable format:&format errorDescription:&a开发者_运维技巧nError];
 if (anError != nil){

  [anError release];
 }

The above code causes a memory leak every time I call it. I am releasing the error but still there is a leak. I haven't seen any resolution to this issue. I posted this already and most respond that this is not a leak. But see here in the leak performance tool:

Nasty NSPropertyListSerialization Leak

I need this fixed because eventually my app crashes. Any ideas? Many thanks


I had the same problem. Used propertyListWithData:options:format:error: with same result. Used NSDictionary initWithContentsOfFile with same result:

Leaked Object # Address Size Responsible Library Responsible Frame NSCFNumber,19 < multiple > 304 Bytes MediaToolbox FigRemote_CreatePropertyListFromBinaryPListData

FWIW - I only have dictionaries and arrays and strings in the pList, no numbers.

The issue is not the error object (or string in your method). The issue is not plist above, since it should be autorelease. In the end, I gave up and reimplemented using JSON and:

http://stig.github.com/json-framework/api/index.html

==> no more leak.

Best, Fred


I've had the same problem before.

Basically this is because your error variable got released without initiating it. So what you can do is try to init your NSString *error to an empty string before releasing it. Or not releasing it at all.

0

精彩评论

暂无评论...
验证码 换一张
取 消