Forum Xamarin.iOS

Garbage Collector not working on device.

RafaelRomero.8190RafaelRomero.8190 USMember
edited July 2017 in Xamarin.iOS

When I run xcode instruments and I profile on the emulator, my UiViewControllers Dispose methods are being called instantly after the view is removed. But when I run the app on the device, the dispose methods of all the UiViewController are never being called!. Or are called very slowly and the memory gets too high.

I don't know why this is happening. The problem is that the only way to get the app, in the device, to call the dipose methods is when I manually perform a Gc.Collect() in the AppDelagate ReceiveMemoryWarning and DidEnterBackground(). When any of those methods executes, the memory drops from 140MB+ to 70MB.

This is the image of the memory when app is running on the emulator.

And when I run the app on the device.

As you can see on the emulator the dispose methods are being called every time a UIviewcontroller is remove. But in the device, the dispose methods are never called. The drop that you see in the image of the device is when the app goes to beckground and I manually call a GC.Collect().

Why isn't doing it automatically in the ios device, like it does in the emulator?

I am very new to xamarin, I have spent 4 days trying to figure this out. I really don't know what to do.

I hope someone can help me.

Sign In or Register to comment.