Android Question Out Of Memory

Agnetha

Member
Licensed User
Longtime User
Hi!

I got an Out Of Memory error when reading my Json-String two times.
Even when i close and reopen the app.
The stringsize is 800kbytes big.


Sub Globals

Dim Map1 as Map
Dim lstDaten as List

end sub

Sub ReadData

Dim json as JSONParser
JSON.Initialize(File.GetText(File.DirInternal, filename))
Map1 = JSON.Nextobject
lstDaten = Map1.Get("aaData")

End Sub
 

Agnetha

Member
Licensed User
Longtime User
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
java.lang.OutOfMemoryError
at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:94)
at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:114)
at java.lang.StringBuilder.append(StringBuilder.java:249)
at anywheresoftware.b4a.objects.streams.File$TextReaderWrapper.ReadAll(File.java:568)
at anywheresoftware.b4a.objects.streams.File.GetText(File.java:209)
at dhs.mallorca.app.main._daten_einlesen(main.java:4220)
at dhs.mallorca.app.main._webview1_pagefinished(main.java:7542)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:173)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:161)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:157)
at anywheresoftware.b4a.objects.WebViewWrapper$1.onPageFinished(WebViewWrapper.java:60)
at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:327)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4793)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:808)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:575)
at dalvik.system.NativeStart.main(Native Method)
 
Upvote 0

Agnetha

Member
Licensed User
Longtime User
I used to read it twice , e.g. when the user changed the language of the app.
Now i don't do it anymore, but the error is still there when restarting the app.
No, i do not load large images.
The app used to function without errors, for a long time.
Now the json string is a little bit bigger.
In the assets folder i put a 19MB OSM-Map for offline Map-View.
Maybe i have to do it without that. I will try...
 
Upvote 0

Agnetha

Member
Licensed User
Longtime User
...still the same error.
What helped was using "ExitApplication" in Activity_Pause.
Anyway, thanks for Reply!
 
Upvote 0

eps

Expert
Licensed User
Longtime User
How do you use the Map? What physical size is it, in terms of pixels?

What device are we talking about?

Have you tried large heap?

Have you tried Dimming the Jsonparser in Globals? i.e. reusing the same memory space when it's called again?

Erm, think that's about as much as I can dredge up off the top of my head.

You might be able to try and recycle the memory used - but if it's used quickly in succession that won't necessarily help.
 
Upvote 0

Agnetha

Member
Licensed User
Longtime User
Tried it without integrated offline Map.
Tried it on several devices.
Dimmed JSON in Process_Globals.
Tried large heap. (after i read about it from you )
All this had no effect.
At last only "ExitApplication" worked fine. Now i can close and reopen the App
in quick succession.

Thanks!
 
Upvote 0

eps

Expert
Licensed User
Longtime User


Have you tried using Memory Manager (downloadable App) and seeing how much memory it is attempting to grab?

Which device make is it? Samsung?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…