Android Question is Out Of Memory ?


Licensed User
Longtime User
How to understand that your app is near the crash due to OutOfMemory ?

Thanks to Informatix, that shared the sub:
Sub GetFreeMem As Float
   Dim r As Reflector
   Dim MM, TM, FM, Total As Int
   r.Target = r.RunStaticMethod("java.lang.Runtime", "getRuntime", Null, Null)
   MM = r.RunMethod("maxMemory")
   FM = r.RunMethod("freeMemory")
   TM = r.RunMethod("totalMemory")
   Total = MM + FM - TM
   Return Total / 1024
End Sub

I have tried some times:
Android 4.0 512 MB RAM: 128_0.15_11.07
Android 4.2 1GB RAM: 256_0.02_10.0
Android Emulator BlueStacks 4.4 768 MB RAM: 512_2.72_17.4

If to measure after start my app - difference is about 10240. So, it's used by my app. I guess, it's 10 MB ... :)
And i have and had no issue with OutOfMemory errors.

But Google Analytics reports show that many user's devices with 1 GB RAM generate OutOfMemory app hungs (not for bitmaps directly, in subs
OutOfMemoryError (@httpjob....) and others working with data objects).

So, how to correctly understand that RAM is so out that app can be stopped any next second ?
What digits are the limit ? For any device.

Does it mean that those devices with errors have result Total = MM + FM - TM that is some small digit (say < 1 MB), many apps are loaded and cannot be freed\unloaded by the OS ?
Last edited:


Licensed User
Longtime User
No, just Analytics logs, attached

Question is how to check\calculate memory status, that we are going to the crash.

BTW, i have found that UnsupportedOperationException (@GLES20Canvas) error under Android 4.0.x is kind of the OOM error !

If to restart the app several times on the same device - sometimes app start OK without UnsupportedOperationException (@GLES20Canvas) error, and mostly - with this error, and firstly got FreeMemory amout by Informatix code sample - is around 0.0x MB value. But not stable to understand what the limit is.

When no error FreeMemory is always > 0.7 MB.
Last edited:
Upvote 0