开发者

NSURLConnection and NSData leaking memory

开发者 https://www.devze.com 2023-01-19 18:44 出处:网络
So I was wondering if this was a common problem to be leaking memory using NSData to store a connection reponse data.For example, I have this line to initialize my data object

So I was wondering if this was a common problem to be leaking memory using NSData to store a connection reponse data. For example, I have this line to initialize my data object

davData = [[NSMutableData data] retain];

And then when the connection errors or finishes loading, I release it. From my understanding, that should not be a leak correct? For so开发者_如何学运维me reason, the data is still showing up in instruments even after I release it. Any idea what could be causing this? Thanks!


Try initializing it like this:

davData = [[NSMutableData alloc] init];

The way you are doing it does not really create a leak, but it is dependent on your object being autoreleased by the system which is probably why you still see it.

0

精彩评论

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

关注公众号