简体   繁体   中英

NSURLConnection and NSData leaking memory

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 some 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM