Memory leak by CFNetwork?

Featured Image

It’s been a while since I wrote my last post. Since then I got married, completed faculty, finished three iPhone applications for clients and three internal. Well, these are the main reasons for my absence and I think they are justified. πŸ™‚

Now lets get back on memory leak issue created by CFNetwork class. If you create NSURLConnection object you will get this memory leak. First time I meet with this issue I was thinking it was my fault as developer, but when I tracked leak I realized that memory leak is created by framework internally. Instruments tool says clearly – “Responsible caller – CFNetwork”.

Well, this is my own conclusion and I might not be right but considering all given facts the leak is created by CFNetwork class. Also, I am not only one developer that has same issue. Many of iPhone developers has complain on same memory leak created by CFNetwork class. To solve this issue I try to put autoreleas pool like code below but no luck.

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

[pool release];

Also I tried to create NSURLCache object like code below but no luck.

NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil];
[NSURLCache setSharedURLCache:sharedCache];
[sharedCache release];

If any of you has meet similar issue or maybe has solution for this memory leak please leave comment bellow. Thanks! πŸ™‚


7 comments

  1. Am having the same issue …is there a solution ? after 2 or 3 times i get memory warning due to these …

  2. Thanks for sharing this, now I don’t feel that bad about my app :-). I am profiling my iPhone app with Instruments now and getting the same leaks (in NSURLCache), except that it is when using UIWebView. With almost no code from my side, it leaks memory, when browsing.

  3. “It’s been a while since I wrote my last post. Since then I got married, completed faculty, finished three iPhone applications for clients and three internal.” – Golden quote! πŸ˜€

    So your last post was like a month ago? πŸ˜€

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <blockquote cite=""> <code> <del datetime=""> <em> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.