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.
First I create an Image from a MemoryStream like so:
var enc = "<imageAsBase64>"; // see link to forum or my code below for real example
var arg = System.Convert.FromBase64String(enc);
var ms = new LoggingMemoryStream(arg);
var img = new LoggingImage();
var src = ImageSource.FromStream(() => ms);
img.Source = src;
Running in the simulator on iOS 10.2: When the Image gets out of scope, its destructor is called like expected. But the destructor of the underlying MemoryStream is never being called. To me that seems to be a bug and a possible memory leak.
~LoggingMemoryStream() is implicitly calling the finalizer (https://msdn.microsoft.com/en-us/library/66x5fx1b.aspx), but there are no guarantees on when it occurs. If you override Dispose in the LoggingMemoryStream class and add a breakpoint, you'll notice that it's being called, so presumably it's already destroyed before the finalizer would even need to be called. I don't believe this is an issue. If you want to safely guarantee its disposal you can also wrap it in a using block.