How to understand that your app is near the crash due to OutOfMemory ?
Thanks to Informatix, that shared the sub:
I have tried some times:
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 ?
Thanks to Informatix, that shared the sub:
B4X:
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:
B4X:
MaxMemory_FreeMemory_TotalMemory:
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: