[英]Memory leak when parse JSON string using SBJSON
I am using following code to parse JSON and getting memory leak (100%) on line number 2. I don't know what is the problem, can someone help me ? 我正在使用以下代码来解析JSON,并在第2行获得内存泄漏(100%)。我不知道这是什么问题,有人可以帮助我吗?
NSString *response = [request responseString];
NSMutableDictionary *responseJSON = [response JSONValue]; (100% leak)
NSString *tockenString = [responseJSON objectForKey:@"Token"];
NSString *userIDString = [responseJSON objectForKey:@"ID"];
I found the answer. 我找到了答案。 Go to SBJsonParser.m function scanRestOfString and change the line
转到SBJsonParser.m函数scanRestOfString并更改行
from 从
*o = [[NSMutableString alloc] initWithBytes:(char*)c length:len encoding:NSUTF8StringEncoding];
to 至
*o = [[[NSMutableString alloc] initWithBytes:(char*)c length:len encoding:NSUTF8StringEncoding] autorelease];
SBJsonParser has a like in scanRestOfString/NSMutableString. SBJsonParser在scanRestOfString / NSMutableString中有一个赞。 I reported the bug as well.
我也报告了该错误。 Thank you all.
谢谢你们。
Remove those 2 autoreleases. 删除这两个自动发行。 They overrelease the objects.
他们过度释放对象。
I've had a similar problem but it turned out the leak was actually higher in the chain of methods, but Instruments was (mistakenly) pointing to this line. 我遇到了类似的问题,但事实证明,方法链中的泄漏实际上更高,但是Instruments(错误地)指向这条线。 Look at the methods that store the results retrieved from this code.
查看存储从此代码检索的结果的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.