Memory leak occurs only on ios 10.x devices, but fine on ios 9.3

ergerglexbossergerglexboss USMember ✭✭

In our legacy project we are struggling with a strange problem: there is a memory leak which occurs on iOS 10.x (at first memory warning signal received then app crashes), but everything is fine on iOS 9.3. Both simulators and devices show same behaviour.
I can't debug it with XCode Instruments due to known deadlock problem. But I was able to see that there is really a problem by use of Xamarin Profiler.

Clearly seen 9.3-sim (top) releases used memory, but 10.0 (bottom) doesn't! (some time-offset of memory pressure is seen because I hit the button later then at the first time)

Memory allocation history (with dead objects). 9.3 - left. 10.0 - right.

Memory allocation history (only live objects). 9.3 - left. 10.0 - right.

Byte array objects for 10.0 simulator. They are alive! But list of paths to root is empty!

Same objects for 9.3 simulator. They are dead as expected to be.

And now look at the call tree for one of those byte-array objects:

This is a 9.3 sim. After the call of the method AsJpeg(System.nfloat), as expected NativeBitmap.Dispose() is called.

But how looks call tree for 10.0 simulator?

Aaaaand there is no Dispose() call :-(

But if I put breakpoint in Dispose method it's hited. Or if I put console output in Dispose's last line it's also printed. I think something breaks when AsJpeg method called.

I've created a sample project that reproduces the issue Screens are taken from it (commit sha 8985627214e6ca259c4ffb835211eaf9550e3805)

Sign In or Register to comment.