Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 06-03-2008, 05:34 PM   #1 (permalink)
New Member
 
Join Date: Apr 2008
Location: Onomatopoeia, Lugubriousylvania
Posts: 225
Default CFNetwork sendDidReceiveDataCallback autorelease "leak"

I'm at the point where I'm profiling and optimizing my application. I'm seeing a situation where CFNetwork sendDidReceiveDataCallback is creating a slew of very large objects (GeneralBlock-32768) and, from what I can tell, leaving them in my app's main autorelease pool (created in the main() function).

This is OK if the application is only used for a few minutes, but after a while they really add up, taking something like 5/7ths of all the memory used by the application. Because they're in the main autorelease pool, they're never released until the app is closed.

I've tried wrapping various network-intensive portions of the app with my own inner autorelease pools, and draining those as appropriate; however, it looks like these allocations are not added to that autorelease pool-- instead they're added to the main autorelease pool in CFRunLoopRunInMode.

Any suggestions on how I can occasionally clean out these allocations?
bonehead is offline   Reply With Quote
Old 06-03-2008, 06:48 PM   #2 (permalink)
New Member
 
Join Date: Apr 2008
Posts: 802
Default Re: CFNetwork sendDidReceiveDataCallback autorelease "leak"

I'd report it as a bug.
scottiphone is offline   Reply With Quote
Old 06-04-2008, 10:04 AM   #3 (permalink)
New Member
 
Join Date: Apr 2008
Posts: 420
Send a message via AIM to jeff_lamarche Send a message via Yahoo to jeff_lamarche
Default Re: CFNetwork sendDidReceiveDataCallback autorelease "leak"

I would report it as a bug, but as a workaround, have you tried wrapping the calls that generate this in their own autorelease pool? Though it shouldn't be necessary - callbacks should be happening on the main thread (the thread from which they are called) unless documented otherwise, and the main thread always has an autorelease pool.

Or, are you perhaps, setting the callback from within a thread? In that case, the callback will probably function on that thread, and if your thread method has ended and released its autorelease pool, then that would explain the problem. You can fix that problem by calling a method on the main thread to set the callback.

But if you're doing everything in the main thread, then I'd definitely file it as a bug, and try wrapping the calls to like this as a workaround:

Code:
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
...code that generates leak message
[pool release];
__________________
Check out my iPhone Dev Blog
You can send me e-mail at my forum username at mac dot com.
jeff_lamarche is offline   Reply With Quote
Old 06-04-2008, 02:45 PM   #4 (permalink)
New Member
 
Join Date: Apr 2008
Location: Onomatopoeia, Lugubriousylvania
Posts: 225
Default Re: CFNetwork sendDidReceiveDataCallback autorelease "leak"

Yeah I'm not explicitly creating a separate thread, I'm simply loading network data using NSURLConnection.

I've tried wrapping the NSURLConnection instance with an autorelease pool such that I create a new pool before creating the NSURLConnection, and then drain the pool after the NSURLConnection completes. However, the app's main pool eventually accumulates a bunch of 32768 blocks. Sounds like a bug...
bonehead is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to show "Turn off Airplane Mode..." network dialog? bonehead iPhone SDK Development 8 01-18-2010 11:37 PM
Nicely centered "Loading" spinner (activity indicator) ? bonehead iPhone SDK Development 4 09-01-2009 03:32 PM
CFNetwork sendDidReceiveDataCallback leaking? bonehead iPhone SDK Development 6 01-15-2009 06:02 PM
"Tab bars from scratch in Beta 4" Tutorial question raptorlol iPhone SDK Development 6 05-26-2008 02:39 PM
Problem with "Tab bars with Interface Builder" tutorial christian iPhone SDK Development 0 04-21-2008 11:50 AM


» Advertisements
» Online Users: 257
19 members and 238 guests
14DEV, @sandris, ADY, ArtieFufkin10, ckgni, Dani77, HemiMG, iDifferent, IphoneSdk, jakerocheleau, JasonR, MACralik, NSeven, prchn4christ, Rudy, silverwiz, spiderguy84
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,230
Posts: 380,767
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:53 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0