## Out of memory exception with low memory usage

_Submitted by a community member on 2016-05-05 17:04 UTC_

We are getting out of memory exceptions even at low memory usage and taking as many precautions as I could find like limiting allocations to 8KB as much as possible to avoid being allocated into the LOS which can cause fragmentation after time.

The application does a lot more memory allocation than the average app would but this is not avoidable for our app.

This issue can happen with low memory usage, total application memory usage of 100mb or less, with android reporting 1GB or more of free memory.

the android file /proc/buddyinfo file reports lots of free pages in all the different allocation sizes at the time of the crash.

I have created a test application which you just need to start the app and wait a few hours for it to crash with the OOM.

This is not our normal application our normal application, I have made modifications to increase the cpu usage and memory usage to make this occur sooner. Under normal conditions it only rarely happens and taking much longer to happen but still does happen causing a big problem for us.

On real nexus 5 and 7 it happens in less than 2 hours. On a galaxy note 2 it happens after about 1 hour.

I have tested with the latest android sdk 6.0 x86\_64 emulator configured as a nexus 5, it does not happen.

I split the app into 5 rar parts because of your upload restriction.

Please install the apk and also place the 2 other files at /sdcard/Folder5500.zip and at /sdcard/Resources.res

Then just launch the app and wait for it to crash with the OOM.

Every 30 seconds I write read /proc/meminfo and /proc/buddyinfo and check "dumpsys activity oom" put this into the android log to track the memory usage in detail.

I have also been forcing the garbage collector every 30 seconds, I know this should not be necessary if the mono runtime was working well but it did have an impact in reducing the OOM from happening (so maybe there is an issue in the garbage collector)

I am available to do any other changes you may require to the test app or assist in any way possible. Please let me know any questions you have.

I will attach a logcat from a galaxy note 2 that contains the OOM error

Here are my system details 
=== Xamarin Studio Enterprise ===

Version 5.10.3 (build 51)
Installation UUID: ce6a42b0-ba4b-4ea6-8535-b03f0d0d3af4
Runtime:
```
	Microsoft .NET 4.0.30319.42000
	GTK+ 2.24.23 (MS-Windows theme)
	GTK# 2.12.30
```

=== Xamarin.Profiler ===

Not Installed

=== Xamarin.Android ===

Version: 6.0.2.2 (Xamarin Enterprise)
Android SDK: C:\\Program Files (x86)\\Android\\android-sdk
```
	Supported Android versions:
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.3   (API level 18)
		4.4   (API level 19)
		5.0   (API level 21)
		5.1   (API level 22)
		6.0   (API level 23)
```

SDK Tools Version: 25.1.3

SDK Platform Tools Version: 23.1

SDK Build Tools Version: 23.0.3

Java SDK: C:\\Program Files (x86)\\Java\\jdk1.7.0\_55
java version "1.7.0\_55"
Java(TM) SE Runtime Environment (build 1.7.0\_55-b13)
Java HotSpot(TM) Client VM (build 24.55-b03, mixed mode, sharing)

Android Designer EPL code available here:
<https://github.com/xamarin/AndroidDesigner.EPL>

=== Xamarin Android Player ===

Version: 0.6.5
Location: C:\\Program Files\\Xamarin Android Player\\DeviceManager.exe

=== Build Information ===

Release ID: 510030051
Git revision: f3c0d982165f785772d125f02668370d929014fb
Build date: 2016-03-24 16:41:31-04
Xamarin addins: ee5cfd3ecb6b20de47c1d25efb9a9abc101e8ce7
Build lane: monodevelop-windows-cycle6-c6sr3

=== Operating System ===

Windows 10.0.10586.0 (64-bit)

* * *

_Reference: <https://bugzilla.xamarin.com/show_bug.cgi?id=40912>_