Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Possible leak from NSURLConnection sendSynchronousRequest on iPhone



Switching to async is not ideal for me, unless you can suggest another way to simulate blocking I/O. I'm running each connection on a distinct thread.

As such, I changed my setup code to ignore the cache:

NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60.0];

This seems to have suppressed the leak, although I'm now seeing another 3.5KB leak stemming from an NSOperation:

  12     3.50 Kb     0x0
  11 libSystem.B.dylib    3.50 Kb     _pthread_body
  10 Foundation    3.50 Kb     __NSThread__main__
   9 Foundation    3.50 Kb     -[NSThread main]
   8 Foundation    3.50 Kb     -[NSOperation start]
   7 Foundation    3.50 Kb     -[NSObject(NSKeyValueObserverNotification) didChangeValueForKey:]
   6 Foundation    3.50 Kb     NSKVONotify
   5 Foundation    3.50 Kb     +[NSOperation observeValueForKeyPath:ofObject:change:context:]
   4 Foundation    3.50 Kb     __finishedOp
   3 Foundation    3.50 Kb     __scheduleAll
   2 Foundation    3.50 Kb     -[NSThread start]
   1 libSystem.B.dylib    3.50 Kb     pthread_create
   0 libSystem.B.dylib    3.50 Kb     malloc

I don't think this is networking related, but is still somewhat mysterious.

- Ladd

On Nov 12, 2008, at 1:10 PM, Mark Pauley wrote:

So it turns out we were aware of this issue, and we know what's wrong.  We should address this at some point in the future, but for now please stick with the asynchronous version of the API to avoid the leak.  Alternatively, I believe that turning off the NSURLCache on a per request basis may work around this.

Please let me know if either of those two don't work for you.

thanks!

On Nov 10, 2008, at 3:18 PM, Mark Pauley wrote:

That's interesting.  It could be a leak... what API are you using?

It's interesting that it only happens with sendSynchronousRequest:returningResponse:error...

I'll mock up a quick test to see if I can't reproduce.


On Nov 10, 2008, at 2:27 PM, Ladd Van Tol wrote:

So I have an iPhone app that makes a number of threaded calls to -[NSURLConnection sendSynchronousRequest:returningResponse:error:]. When I run the app on the device with the Leaks instrument, I get a periodic 3.5KB leak. So far I haven't been able to tie this leak back to any specific network calls on my part, owing to the async nature of the CF networking stuff.

Instruments reports the attached stack trace.

Any thoughts? Is this a real leak?

Thanks,

Ladd

33 libSystem.B.dylib   17.50 Kb     malloc
32 libSystem.B.dylib   17.50 Kb     pthread_create
31 libSystem.B.dylib   10.50 Kb     si_async_call
30 libSystem.B.dylib   10.50 Kb     getaddrinfo_async_call
29 libSystem.B.dylib   10.50 Kb     getaddrinfo_async_start
28 CFNetwork   10.50 Kb     _CreateMasterAddressLookup
27 CFNetwork   10.50 Kb     CFHostStartInfoResolution
26 CFNetwork   10.50 Kb     CFHostStartInfoResolution
25 CFNetwork   10.50 Kb     _ScheduleAndStartLookup
24 CFNetwork   10.50 Kb     _SocketStreamStartLookupForOpen_NoLock
23 CFNetwork   10.50 Kb     _SocketStreamOpen
22 CoreFoundation   10.50 Kb     _CFStreamOpen
21 CoreFoundation   10.50 Kb     CFWriteStreamOpen
20 CFNetwork   10.50 Kb     httpWrFilterOpen
19 CoreFoundation   10.50 Kb     _CFStreamOpen
18 CoreFoundation   10.50 Kb     CFWriteStreamOpen
17 CFNetwork   10.50 Kb     scheduleNewRequest
16 CFNetwork   10.50 Kb     _CFNetConnectionEnqueue_internal
15 CFNetwork   10.50 Kb     _CFNetConnectionEnqueue
14 CFNetwork   10.50 Kb     httpStreamOpen
13 CoreFoundation   10.50 Kb     _CFStreamOpen
12 CoreFoundation   10.50 Kb     CFReadStreamOpen
11 CFNetwork   10.50 Kb     createAndOpenStream
10 CFNetwork   10.50 Kb     httpProtocolStart
9 CFNetwork   10.50 Kb     CFURLProtocolStartLoad
8 CFNetwork   10.50 Kb     _CFURLConnectionProcessServerEvents
7 CFNetwork   10.50 Kb     muxerSourcePerform
6 CoreFoundation   10.50 Kb     CFRunLoopRunSpecific
5 CoreFoundation   10.50 Kb     CFRunLoopRunInMode
4 Foundation   10.50 Kb     +[NSURLConnection(NSURLConnectionReallyInternal) _resourceLoadLoop:]
3 Foundation   10.50 Kb     -[NSThread main]
2 Foundation   10.50 Kb     __NSThread__main__
1 libSystem.B.dylib   10.50 Kb     _pthread_body

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/macnetworkprog/email@hidden

This email sent to email@hidden

_Mark
email@hidden




_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/macnetworkprog/email@hidden

This email sent to email@hidden

_Mark
email@hidden






 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/macnetworkprog/email@hidden

This email sent to email@hidden

References: 
 >Possible leak from NSURLConnection sendSynchronousRequest on iPhone (From: Ladd Van Tol <email@hidden>)
 >Re: Possible leak from NSURLConnection sendSynchronousRequest on iPhone (From: Mark Pauley <email@hidden>)
 >Re: Possible leak from NSURLConnection sendSynchronousRequest on iPhone (From: Mark Pauley <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.