0

I have an app that is nearly ready for release which we have coded in Xamarin.iOS and although it is working really well functionally, the app is having memory leaks left right and centre. This is no doubt a common issue for most developers of Xamarin.iOS as I have read many accounts that say memory management on this platform is not exactly what it may seem to be. Even though I have been disposing views, correctly asking the GC to collect and using dispose methods where I can, it still is leaking memory everywhere with no logical or obvious explanation as to why.

I have come across methods that can support with memory deposition such as this one - Xamarin iOS memory leaks everywhere but I am finding it difficult to identify and be clear on what exactly is leaking memory.

The app is very simple with not many images or text, just almost static informational pages throughout with simple functionality, yet still it is leaking. I am not able to use the Xamarin Profiler to find out what exactly is leaking as I do not have an Enterprise subscription for this and I also find profiling with Instruments to be cumbersome and not very helpful as all it identifies are memory leaks but not exactly what data is leaking or in what method or part of the code.

I would like to know more from the community of what other people use for profiling an Xamarin iOS app and also the bottom line answer - is Garbage Collection working in Xamarin and if there is anything special I must do to get it working, what would that be?

Thank you everyone.

Community
  • 1
  • 1

1 Answers1

1

You can use Apple's Instruments for profiling if need be. I'll ask if you're unsubscribing event handlers -- though if it's as big of a problem as you say it is, I have my doubts that event handlers alone could cause the issue. Other common memory leak culprits include singletons and timers. I'll also ask what makes you think you have memory leaks -- perhaps you just have a large app in which case the Xamarin Linker or fewer generics may help.

kellen lask
  • 40
  • 1
  • 2
  • Thanks for sharing this @kellen. You have a point. I know there are memory leaks of some sort as when I go into one screen then back out then into this screen again then back out and so forth, the memory usage as shown in Apple's Instruments keeps climbing. Plus Instruments does say there are leaks each time. It probably is a combination of both the app size and memory leaks. – Joshua Campbell Mar 19 '17 at 04:45
  • make sure you are unsubscribing to events, I had memory leaks too and took a while to fix, in ViewDidDisappear I unsubscribe to all event handlers, such as TouchUpInside on UIButtons – MattjeS May 06 '17 at 19:11