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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development > iPhone SDK Development - Advanced Discussion

Reply
 
LinkBack Thread Tools Display Modes
Old 05-28-2010, 04:45 PM   #1 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 140
MatthewD is on a distinguished road
Default CFNetwork Memory Leak?

I am attempting to use NSURLConnection to talk to a device that supports HTTP. It works great, but I noticed there are occasional memory leaks when using the Leak instrument. I have a RequestHelper class that has its own secondary thread. The secondary thread is there to parse and process the data when it arrives from the URLConnection. Here is the stack trace I get for the leak:

EDIT: I have also tried removed the secondary thread and created the connection in the main thread with the same results.

Code:
  20 libSystem.B.dylib thread_assign_default
  19 libSystem.B.dylib _pthread_start
  18 Foundation __NSThread__main__
  17 Foundation -[NSThread main]
  16 Server Control -[RequestHelper backgroundThread:] /.../Server Control/Classes/RequestHelper.m:593
  15 CoreFoundation CFRunLoopRunInMode
  14 CoreFoundation CFRunLoopRunSpecific
  13 CFNetwork MultiplexerSource::_perform(void*)
  12 CFNetwork MultiplexerSource::perform()
  11 CFNetwork URLConnection::multiplexerClientPerform(RunLoopMultiplexer*)
  10 CFNetwork URLConnectionClient::processEvents()
   9 CFNetwork URLConnectionClient::ClientConnectionEventQueue::processAllEventsAndConsumePayload(XConnectionEventInfo<XClientEvent, XClientEventParams>*, long)
   8 CFNetwork URLConnectionClient::_clientWillSendRequest(_CFURLRequest const*, _CFURLResponse*, URLConnectionClient::ClientConnectionEventQueue*)
   7 CFNetwork URLConnectionClient::getRequestForTransmission(_CFURLResponse*, _CFURLRequest const*, __CFError**)
   6 CFNetwork URLConnectionLoader::copyProtocolCanonicalRequest()
   5 CFNetwork HTTPProtocol::copyCanonicalRequest()
   4 CFNetwork HTTPProtocol::_createCanonicalRequest(__CFAllocator const*, _CFURLRequest const*, void const*)
   3 CFNetwork HTTPProtocol::_createMutableCanonicalRequest(__CFAllocator const*, _CFURLRequest const*, void const*)
   2 CFNetwork createCanonicalURL
   1 CoreFoundation CFAllocatorAllocate
   0 CoreFoundation __CFAllocatorSystemAllocate
Now, I've been pretty frustrated trying to figure this out, so I created a stripped down, basic version of the URLConnection class with similar methods and the same delegate methods (Basically, just a TCPClient that parses the response and the content). When replacing my version of the URLConnection into RequestHelper class and changing nothing else, I no longer have any leaks. I really don't want to use the stripped down version because I think it's a waste of time to reinvent the wheel.

This is what is on line 593 in the RequestHelper class:

Code:
RequestHelper.m Line 593:
SInt32 result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 10, YES);
Any thoughts?

Thanks,
Matt

Last edited by MatthewD; 05-28-2010 at 04:48 PM. Reason: tested without secondary thread - same results
MatthewD 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



» Advertisements
» Online Users: 352
5 members and 347 guests
.Snipe, baja_yu, guusleijsten, NSString, Paul Slocum
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,645
Threads: 94,111
Posts: 402,862
Top Poster: BrianSlick (7,990)
Welcome to our newest member, leighec68
Powered by vBadvanced CMPS v3.1.0

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