When using System.Net.WebClient to query web services, monotouch complains about several leaked objects.
var wc = new WebClient();
wc.UploadStringCompleted += (sender, e) =>
this will generate the messages on the console
*** __NSAutoreleaseNoPool(): Object 0xd76edd0 of class NSCFString autoreleased with no pool in place - just leaking
*** __NSAutoreleaseNoPool(): Object 0xd76f330 of class __NSCFDictionary autoreleased with no pool in place - just leaking
*** __NSAutoreleaseNoPool(): Object 0xd76f4e0 of class __NSCFData autoreleased with no pool in place - just leaking
I made a quick test and I do not get the messages (on both the simulator and my iPad). Can you provide a small, self-contained, test case that shows the issue ?
Also state where this occurs (simulator and/or devices), the exact version you're using (5.0.x) and the iOS version used (simulator or device).
^ test case
It looks like the leaks occurs before our `monotouch_thread_start` is called to set a NSAutoreleasePool.
objc: Object 0x9b36cb0 of class __NSCFString autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
objc: Object 0x9b363c0 of class __NSCFData autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
note quite, the Thread is displaying ">OpenReadAsync" so the monotouch_thread_start should have been earlier - but it seems to be used only for the threadpool
WebClient uses Thread (not ThreadPool) which don't use an NSAutoreleasePool instance. Not sure why this did not occur earlier as both Thread and WebClient have not changed recently (I guess something else changed that triggers the warning).
In any case I'm testing code that will ensure all threads will be covered correctly...
Fixed. It will be in MonoTouch 5.2 (and future 5.1.x beta releases).
I will test it a bit more before backporting it to 5.0.x
*** Bug 1839 has been marked as a duplicate of this bug. ***
Will Apple reject the app if it sees those errors? If so, how can I get the patch?
I see 5.1 is available, but not 5.2
I got around it with:
WebClient webClient = new WebClient();
5.2 is not yet released, only the 5.1.x betas are available until then.
This issue has existed for a long time and I never heard about app rejections related this (in general managed applications tends to leak less than native counterparts).
Using the ThreadPool will provide a auto-release pool for you. If that fits your application well (async) then it's a valid workaround.