Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
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.