wimpie3 Well-Known Member Licensed User Longtime User Mar 7, 2016 #1 I seem to be getting an out of memory after adding and removing about 50 bitmaps. There somehow seems to be a memory leak. I've tried to log the current memory usage by using this sub: Code: Sub GetFreeMemory As String Dim ph As ICOSPhone Return ph.UsedMemory & "/" & ph.AvailMemory & "/" & ph.TotalMemory End Sub However, the returned values show there is plenty of memory available (several GB's), even when the app crashes with an out of memory. I probably need to log another value, but how?
I seem to be getting an out of memory after adding and removing about 50 bitmaps. There somehow seems to be a memory leak. I've tried to log the current memory usage by using this sub: Code: Sub GetFreeMemory As String Dim ph As ICOSPhone Return ph.UsedMemory & "/" & ph.AvailMemory & "/" & ph.TotalMemory End Sub However, the returned values show there is plenty of memory available (several GB's), even when the app crashes with an out of memory. I probably need to log another value, but how?
wimpie3 Well-Known Member Licensed User Longtime User Mar 7, 2016 #2 This does the trick: Code: Sub GetFreeMemory As String Dim r As Reflector r.Target = r.RunStaticMethod("java.lang.Runtime", "getRuntime", Null, Null) Return ("available Memory = " & ((r.RunMethod("maxMemory") - r.RunMethod("totalMemory"))/(1024*1024)) & " MB") End Sub Upvote 0
This does the trick: Code: Sub GetFreeMemory As String Dim r As Reflector r.Target = r.RunStaticMethod("java.lang.Runtime", "getRuntime", Null, Null) Return ("available Memory = " & ((r.RunMethod("maxMemory") - r.RunMethod("totalMemory"))/(1024*1024)) & " MB") End Sub
MaFu Well-Known Member Licensed User Longtime User Mar 7, 2016 #3 On Android, Java cannot use all available memory. Therefore if an app uses many or big images it runs often out of memory. If you have no memory leak and the bitmaps are the problem then try to add SetApplicationAttribute(android:largeHeap, "true") in the manifest editor. Upvote 0
On Android, Java cannot use all available memory. Therefore if an app uses many or big images it runs often out of memory. If you have no memory leak and the bitmaps are the problem then try to add SetApplicationAttribute(android:largeHeap, "true") in the manifest editor.