How to find memory leaks in Xamarin

AmolGaikwad.8043AmolGaikwad.8043 Amol GaikwadINMember

Hi Guys,

I have developed one application. But i am facing lots of memory related issues App crashing several times but i unable to track where that crash happening exactly.

I have tried Xamarin Profiling option but its just showing Allocated objects Its not showing Leaked objects at all.

Even i tried apple instrument but after running app 5 to 10 through Instrument app crashing.

Any kind help will be highly appreciated.

Thanks
Amol

Best Answers

Answers

  • I_am_a_duckI_am_a_duck Philip Hopkins GBUniversity ✭✭

    I have the 14-Jan release (well, downloaded on 24-Jan, so I assume it's the latest; there's no help/about version info in it), but I can't figure out how to make snapshots. Clicking the red flag, tooltip 'snapshot' appears to do nothing.

    I'm running it on Windows 8.1 with an Android app, launching from Visual Studio 2013 (after finding the exe!). Am I missing something? I need to be able to create snapshots in order to compare them to find leaks, don't I?

    TIA,
    Philip

  • NinaVyedinNinaVyedin Nina Vyedin USXamarin Team, University, XamUProfessors Xamurai

    Hi Philip - You're right, there is indeed a bug on Windows with that release. We have a new release queued up to go with this fixed. It should be ready by end of the week and announced in the forums.

    Sorry about the regression - Profiler's still in preview to let us work these things out.

    Thanks,
    Nina

  • NinaVyedinNinaVyedin Nina Vyedin USXamarin Team, University, XamUProfessors Xamurai

    This has been fixed in the latest version. click on the red flag to take a snapshot (we will be changing this UX soon, sorry).

  • AmolGaikwad.8043AmolGaikwad.8043 Amol Gaikwad INMember

    As per Comparison with Profiler & Instrument. Instrument is always preferable option for App memory testing.
    Still not happy with Profiler.

  • DavidDancyDavidDancy David Dancy AUMember ✭✭✭✭

    Profiler is OK as far as it goes, but I still don't find it easy to use or even very helpful in debugging issues. If anything, there's too much information presented.

    One thing that is particularly unhelpful for a new user is to observe the thousands of items that appear to be allocated when my app starts up. For a simple Hello World app you can often have tens of thousands of strings allocated even though almost all of them are irrelevant. Therefore what would be most helpful would be a way to distinguish in Profiler between objects allocated by third-party code (including the .NET system itself) and objects managed by my code.

    I can't do anything about all the various DLLs and other cruft that gets automatically included in my app, so having those stats in there is pure noise and not useful information.

    What I'm really interested in is whether I've correctly used the objects that I created; whether I've got circular references anywhere in my code that cause memory leaks, and so on. So the Profiler must provide that information to me automatically if it's going to be a useful tool.

    I have used Instruments on iOS in the past to track down memory leaks and circular dependencies so I would like to be able to do similar things with Profiler.

    Other random thoughts:

    • Automatic (timed) memory snapshots, like Instruments
    • Automatic memory diff chart so I can see easily whether I have leaks
    • Automatic analysis to find circular references that cause leaks
    • Special attributes in code to trigger GC collection or profiler memory snapshots or memory diffs (but only when running under profiler control). This could be useful for debugging a specific screen where there's some kind of leak that's hard to isolate from the rest of the background noise in the system. Perhaps even a special build configuration for profiling.
    • Special attributes to exclude modules / classes from the profiler. If a module is working, having its allocations analysed may just contribute noise rather than signal to the information on display.

    PM me if you would like more information on how I think these features should work.

  • ThanhNgoThanhNgo Thanh Ngo USMember ✭✭

    PLEASE TELL ME HOW TO UNINSTALL XAMARIN PROFILER ?

    Would anyone please tell me how to uninstall the tool "Xamarin Profiler" from Xamarin Studio ? I don't need Xamarin Profiler any longer, and it prevents me from launching my Xamarin app because it always pops up an error message saying that "Trial executable has expired (24 hours limit)".

    The reason is that I only have the Indie license and Xamarin Profiler is only available with one of these 3 types: Business License, Enterprise License, and Trial License. So, I installed Xamarin Profiler with the Trial License, and after 24 hours, I have that weird issue described above.

    Now, I don't need Xamarin Profiler and want to uninstall only Xamarin Profiler and not the whole Xamarin Studio. But there is no instruction on how to uninstall this Xamarin Profiler tool. (There is only guide to uninstall the whole Xamarin Studio).

  • ThanhNgoThanhNgo Thanh Ngo USMember ✭✭

    PLEASE TELL ME HOW TO UNINSTALL XAMARIN PROFILER ?

    Would anyone please tell me how to uninstall the tool "Xamarin Profiler" from Xamarin Studio ? I don't need Xamarin Profiler any longer, and it prevents me from launching my Xamarin app because it always pops up an error message saying that "Trial executable has expired (24 hours limit)".

    The reason is that I only have the Indie license and Xamarin Profiler is only available with one of these 3 types: Business License, Enterprise License, and Trial License. So, I installed Xamarin Profiler with the Trial License, and after 24 hours, I have that weird issue described above.

    Now, I don't need Xamarin Profiler and want to uninstall only Xamarin Profiler and not the whole Xamarin Studio. But there is no instruction on how to uninstall this Xamarin Profiler tool. (There is only guide to uninstall the whole Xamarin Studio).

  • ThanhNgoThanhNgo Thanh Ngo USMember ✭✭

    PLEASE TELL ME HOW TO UNINSTALL XAMARIN PROFILER ?

    Would anyone please tell me how to uninstall the tool "Xamarin Profiler" from Xamarin Studio ? I don't need Xamarin Profiler any longer, and it prevents me from launching my Xamarin app because it always pops up an error message saying that "Trial executable has expired (24 hours limit)".

    The reason is that I only have the Indie license and Xamarin Profiler is only available with one of these 3 types: Business License, Enterprise License, and Trial License. So, I installed Xamarin Profiler with the Trial License, and after 24 hours, I have that weird issue described above.

    Now, I don't need Xamarin Profiler and want to uninstall only Xamarin Profiler and not the whole Xamarin Studio. But there is no instruction on how to uninstall this Xamarin Profiler tool. (There is only guide to uninstall the whole Xamarin Studio).

  • ThanhNgoThanhNgo Thanh Ngo USMember ✭✭

    PLEASE TELL ME HOW TO UNINSTALL XAMARIN PROFILER ?

    Would anyone please tell me how to uninstall the tool "Xamarin Profiler" from Xamarin Studio ? I don't need Xamarin Profiler any longer, and it prevents me from launching my Xamarin app because it always pops up an error message saying that "Trial executable has expired (24 hours limit)".

    The reason is that I only have the Indie license and Xamarin Profiler is only available with one of these 3 types: Business License, Enterprise License, and Trial License. So, I installed Xamarin Profiler with the Trial License, and after 24 hours, I have that weird issue described above.

    Now, I don't need Xamarin Profiler and want to uninstall only Xamarin Profiler and not the whole Xamarin Studio. But there is no instruction on how to uninstall this Xamarin Profiler tool. (There is only guide to uninstall the whole Xamarin Studio).

  • ThanhNgoThanhNgo Thanh Ngo USMember ✭✭

    PLEASE TELL ME HOW TO UNINSTALL XAMARIN PROFILER ?

    Would anyone please tell me how to uninstall the tool "Xamarin Profiler" from Xamarin Studio ? I don't need Xamarin Profiler any longer, and it prevents me from launching my Xamarin app because it always pops up an error message saying that "Trial executable has expired (24 hours limit)".

    The reason is that I only have the Indie license and Xamarin Profiler is only available with one of these 3 types: Business License, Enterprise License, and Trial License. So, I installed Xamarin Profiler with the Trial License, and after 24 hours, I have that weird issue described above.

    Now, I don't need Xamarin Profiler and want to uninstall only Xamarin Profiler and not the whole Xamarin Studio. But there is no instruction on how to uninstall this Xamarin Profiler tool. (There is only guide to uninstall the whole Xamarin Studio).

  • ThanhNgoThanhNgo Thanh Ngo USMember ✭✭

    PLEASE TELL ME HOW TO UNINSTALL XAMARIN PROFILER ?

    Would anyone please tell me how to uninstall the tool "Xamarin Profiler" from Xamarin Studio ? I don't need Xamarin Profiler any longer, and it prevents me from launching my Xamarin app because it always pops up an error message saying that "Trial executable has expired (24 hours limit)".

    The reason is that I only have the Indie license and Xamarin Profiler is only available with one of these 3 types: Business License, Enterprise License, and Trial License. So, I installed Xamarin Profiler with the Trial License, and after 24 hours, I have that weird issue described above.

    Now, I don't need Xamarin Profiler and want to uninstall only Xamarin Profiler and not the whole Xamarin Studio. But there is no instruction on how to uninstall this Xamarin Profiler tool. (There is only guide to uninstall the whole Xamarin Studio).

  • AbinoAbino Abino Done USMember ✭✭

    I have Checked each screen with profiler. If some screen I have transferred data to other screen through objects . In that huge memory is holding and then app get crashed. Can anyone suggest have to solve this. If I am using MapKit ,table view ,Lookup controller huge memory will allocate suddenly the app get crashed. Xamarin is not handling the automatic memory leak. can anyone suggest how to solve this kind of issues.

  • AmolGaikwad.2793AmolGaikwad.2793 Amol Gaikwad USMember

    Its too late but in ios option under the ios debug option you can see profiler just uncheck it.

  • ThanhNgoThanhNgo Thanh Ngo USMember ✭✭
    edited June 2016

    Hello all,

    Sorry if you saw my 4 duplicated messages above posted in April 2015. It was not my intention to do that. It was probably caused by a bug in "Xamarin Forum" software somehow...

    I have never intentionally posted 4 duplicated messages above in April 2015. I guess the system probably had some bugs at that time that accidentally posted 4 duplicated messages at the same time when in reality I only hit the "Post" button ONCE to post the message ONCE.

    Actually, I did not see those 4 duplicated messages at that time on April 2015 until now which is June 2016.

    Now, I wish I can delete those duplicated messages, but I don't know how to delete them either...

    Maybe, Xamarin can give users the ability to delete their own duplicated messages ? It would be great to have that in the future...

    Cheers.

  • DylanLiuDylanLiu Dylan Liu USMember ✭✭

    9 out of 10 times memory leaks on android was caused by large resolution image files in the resource folder not being loaded efficiently.

    There is an official post here:
    https://developer.xamarin.com/recipes/android/resources/general/load_large_bitmaps_efficiently/

    I have my own post trying to solve this for Xamarin.forms
    https://forums.xamarin.com/discussion/81875/fileimagesourcehandler-causes-memory-problems#latest

  • SteveShaw.5557SteveShaw.5557 Steve Shaw USMember ✭✭

    @DylanLiu FWIW, what you are describing is one cause of OOM, but is not a "memory leak". A memory leak is when your app is done with some memory-consuming resource (here, a bitmap), and goes on to some other task, but the memory is still being used.

Sign In or Register to comment.