Looking at used and available memory and using this code, copied from here:
https://www.b4x.com/android/forum/threads/memory-usage.97349/
I get these values:
*** Service (starter) Create ***
Max Memory = 256 Mb
Total Free = 254 Mb
Total Memory = 7 Mb
Used Memory = 2 Mb
Free Memory = 5 Mb
after application fully loaded:
Max Memory = 256 Mb
Total Free = 250 Mb
Total Memory = 11 Mb
Used Memory = 6 Mb
Free Memory = 5 Mb
The last 4 values can vary by a few Mb, this is after the app is fully loaded.
Now, I am not sure what the exact meaning is of these 5 values.
Could somebody explain this to me?
RBS
https://www.b4x.com/android/forum/threads/memory-usage.97349/
B4X:
Sub LogMemory
Dim r As Reflector
Dim iFreeMemory As Int
Dim iMaxMemory As Int
Dim iTotalMemory As Int
Dim iUsedMemory As Int
Dim iTotalFreeMemory As Int
Dim strPrompt As String
r.Target = r.RunStaticMethod("java.lang.Runtime", "getRuntime", Null, Null)
iFreeMemory = r.RunMethod("freeMemory") / (1024 * 1024)
iMaxMemory = r.RunMethod("maxMemory") / (1024 * 1024)
iTotalMemory = r.RunMethod("totalMemory") / (1024 * 1024)
iUsedMemory = iTotalMemory - iFreeMemory
iTotalFreeMemory = iMaxMemory - iUsedMemory
strPrompt = "Max Memory = " & iMaxMemory & " Mb" & _
CRLF & "Total Free = " & iTotalFreeMemory & " Mb" & _
CRLF & "Total Memory = " & iTotalMemory & " Mb" & _
CRLF & "Used Memory = " & iUsedMemory & " Mb" & _
CRLF & "Free Memory = " & iFreeMemory& " Mb"
RunLog(strPrompt)
End Sub
I get these values:
*** Service (starter) Create ***
Max Memory = 256 Mb
Total Free = 254 Mb
Total Memory = 7 Mb
Used Memory = 2 Mb
Free Memory = 5 Mb
after application fully loaded:
Max Memory = 256 Mb
Total Free = 250 Mb
Total Memory = 11 Mb
Used Memory = 6 Mb
Free Memory = 5 Mb
The last 4 values can vary by a few Mb, this is after the app is fully loaded.
Now, I am not sure what the exact meaning is of these 5 values.
Could somebody explain this to me?
RBS