Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin Android application memory usage

I've been looking at the memory usage for a xamarin android app I have created and it was looking rather high compared to other running native android apps on various devices (Around 70Mb after running for a while). I started some investigation around this, initially by comparing the memory usage of my app to other xamarin android apps. I looked at some of the sample apps such as "Employees" (available on the xamarin studio front page or the xamarin site).

I noticed that when this app (and my app) starts they are consistently using around 25-30Mb of RAM straight away, this occurs even if I don't load a layout in the main launcher activity. Is this expected? This seems rather high as many other apps running on android devices may only get this high after running for some days? If so, then I'll just have to do my best to make the rest of the app as efficient as possible, but I wanted to clarify whether this observation has been made by others?

In the meantime I'm looking at the android developer site suggestion on minimizing memory usage (context lifetime and layout hierarchy etc) to do what I can to keep the rest of the memory usage lower.

Having used some of the standard tools (MAT being the main start point) I have struggled to determine exactly what is using up this memory.

So my questions are: Is this a typical amount of memory for a Xamarin Android app to be consuming when the first activity is loaded (even before layouts are loaded) and what are the best xamarin compatible tools for determining how much memory each process is using.

like image 352
Philip Rich Avatar asked Sep 14 '14 12:09

Philip Rich


1 Answers

This mailing list thread might be interesting: http://mono-for-android.1047100.n5.nabble.com/RAM-Usage-of-applications-written-with-monodroid-td5711289.html (it's from 2012, so it's likely there have been improvements since then).

Some key points:

I'm interested in the RAM usage of applications. We wrote an application with monodroid, that uses augmented reality, and it's usage is usually 50MB-60MB.

Note that adb shell ps numbers are notoriously misleading [...]. To determine the Mono GC heap size, you should use GC.GetTotalMemory()

You might also want to take a look at Memory and Performance Best Practices and the Garbage Collection articles in Xamarin's docs.

like image 68
Alexander Köplinger Avatar answered Oct 13 '22 22:10

Alexander Köplinger