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.
Steps to reproduce:
In a new Mono/Xam mac application, drop a button and write the following event handler:
partial void RunTest(NSObject sender)
for (int i = 0; i < 10000; i++)
using (NSData obj = NSData.FromArray(new byte))
using (NSData key = NSData.FromArray(new byte))
using (NSDictionary attr = NSDictionary.FromObjectAndKey(obj, key))
Or use the attached project.
Every time you press the button, the application leaks about 1GB of memory. If opened with Apple Instruments, the NSDictionary instances aren't being freed.
This seems to happen only in Mono/Xam mac, not in MonoTouch.
Created attachment 4522 [details]
The GC.Collect there could contains some false positives from the obj and key still being around.
In my case, it takes a couple of seconds, but Activity Monitor shows the memory going back to a baseline (baseline, because the GC can not always return all the memory to the OS, only memory that is completely empty, and the above would likely create some fragmentation at some point).