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 for Bug 20975 on
GitHub or Developer Community if you have new
information to add and do not yet see a matching new report.
If the latest results still closely match this report, you can use the
In special cases on GitHub you might also want the comments:
GitHub Markdown with public comments
g_dbus_connection_call_sync() returns a strong ref on the reply GVariant. The generated code does:
Which internally does a g_variant_ref_sink() and since the GVariant is not floating that adds a 2nd ref on it. When the managed code decide to dispose the variant, it does a single g_variant_unref() and it gets leaked. CallFinish() has the same issue AFAIK.
Also related to this: If the call fails it will return null but the generated code will still try to create a new GLib.Variant for it, leading to some g_warning().
Created attachment 7232 [details]
Created attachment 7233 [details]
Memory leak test case
Xavier's first patch does not fix the problem for me.
Attached is a memory-eating test case, which will bring machines without much RAM to their knees within seconds. Looks like each iteration of CallSync leaks about a meg of RAM.
Looks like there is a 2nd problem: Variant is a IDisposable so they always have to be wrapped inside a using() statement. With your testcase Variant::Dispose() is never called.
Created attachment 7234 [details]
It seems that all objects coming from glib# or gio# must be wrapper with 'using'. With my patch this new testcase seems to not leak.