1

I made app and launched with using Xamarin.forms.

I'm wondering how I can profile my app and check memory allocation and leaks. For now, (2016/12/2) iOS instruments not working for me. It's freezed at the beginning. (I already know freezing is normal behavior, but it's freezed and never come back)

Is this only happening to me? or you guys too?

And I also noticed there is Xamarin profiler. But is this paid program?

How can I check memory leaks?

Thanks.

Bright Lee
  • 2,306
  • 2
  • 27
  • 55
  • https://developer.xamarin.com/guides/ios/deployment,_testing,_and_metrics/using_instruments_to_detect_native_leaks_using_markheap/ – SushiHangover Dec 02 '16 at 15:17
  • @SushiHangover Hi, I already mentioned about instrument. But it's not working for me with current xamarin version. Is this working for you? – Bright Lee Dec 02 '16 at 15:46
  • 1
    You can use the native iOS(Instruments) and Android(Memory Monitor/TraceView) profilers, but please keep in mind that tracking managed memory will not be possible unless you use a tool like the `Xamarin Profiler` or `HeapShot`. – Jon Douglas Dec 02 '16 at 15:50
  • @JonDouglas So can you give me your opinion? Is it worth to purchase Xamarin profiler program? I think tracking managed memory is really important. but it's kind of expensive. – Bright Lee Dec 02 '16 at 15:52
  • 2
    You have full access to the `System.GC` class. You can easily make a poor-man's profiler by spitting out the total memory after certain large allocations. For example you'd call `GC.GetTotalMemory(false);` and log to console/logcat and you can visually see where your memory is increasing. – Jon Douglas Dec 02 '16 at 15:58
  • @JonDouglas Thanks Jon. This is really helpful. – Bright Lee Dec 02 '16 at 16:32
  • @JonDouglas Can you help why my app hangs at launch screen when use allocation of instrument? – nevermore Feb 20 '21 at 02:40
  • @JonDouglas I meet the same problem as mentioned in [this thread](https://stackoverflow.com/questions/27496524/ios-instruments-allocation-and-leaks-crash-the-xamarin-application). – nevermore Feb 20 '21 at 03:03
  • @JackHua Have you tried [asking a question on Stack Overflow](https://stackoverflow.com/help/how-to-ask)? You can also [Open a question with a bounty](https://stackoverflow.com/help/bounty). – Jon Douglas Feb 21 '21 at 23:27
  • Yes, asked a new question [here](https://stackoverflow.com/questions/66308784/ios-app-freezes-when-using-instruments-allocation). Thank you! – nevermore Feb 22 '21 at 00:58

2 Answers2

0

If you want to use the Xamarin Profiler you will need a Visual Studio Enterprise license:

https://www.xamarin.com/profiler

"Xamarin Profiler works with a Visual Studio Enterprise license. It is compatible with Xamarin Studio 5.6 (or higher) and Xamarin for Visual Studio 3.8 (or higher)."

Mario Galván
  • 3,964
  • 6
  • 29
  • 39
0

While its not as convenient (or informative) for a Xamarin developer, on Android you can use the Android profiler on a Xamarin app, once it is packaged as an apk:

https://learn.microsoft.com/en-us/xamarin/android/deploy-test/profiling#android-studio-profiler

This provides some basic cpu/memory over time information.

Also see Jon Douglas' comment above - at various points in your code, write log messages reporting total memory as seen by System.GC (plus where in the code you are).

ToolmakerSteve
  • 18,547
  • 14
  • 94
  • 196