Android Question Out of memory on Galaxy Tablet T3

brodmuehler

Member
Licensed User
Longtime User
Dear All

I am using the DBUtils to display data from my database in a webview. Doing so, I get an error on my T3 which is ...



dbutils_executehtml (B4A line: 42)
sb.Append("<a href='http://").Append(i).Append(".")
java.lang.OutOfMemoryError
at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:94)
at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:145)
at java.lang.StringBuilder.append(StringBuilder.java:216)
at anywheresoftware.b4a.keywords.StringBuilderWrapper.Append(StringBuilderWrapper.java:50)
at b4a.estartliste.dbutils._executehtml(dbutils.java:367)
at b4a.estartliste.liste._fillwebview(liste.java:358)
at b4a.estartliste.liste._activity_create(liste.java:262)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at b4a.estartliste.liste.afterFirstLayout(liste.java:89)
at b4a.estartliste.liste.access$100(liste.java:16)
at b4a.estartliste.liste$WaitForLayout.run(liste.java:74)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4949)
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:1043)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:810)
at dalvik.system.NativeStart.main(Native Method)


There are currently appr. 1000 datasets in the database with 24 different collumns. Usually the error appears after 130 datasets are appended in the stringbuilder.

Any idea what I could do to overcome this issue? Any help is highly appreciated since this is a real threat to my app. Is there any alternative to the stringbuilder like creating the string in a text file? Is the webview object suitable to show a bigger number of datasets? There is much more to come than the 1000 datasets I have at the moment.

Thanks a lot in advance for your help.
Kind regards from sunny Germany.
René
 

eps

Expert
Licensed User
Longtime User
Without seeing any code it's a little hard to help...

Start by using Memory Viewer or similar and work out how much memory your App devours.

Look at variable reuse as opposed to declaring new variables. Maybe globally defined.

Try and tighten up the code to be more efficient and reduce any bitmaps used.

Look atlarge memory heap allocation.

Look around for other solutions which use different memory stores.

TheSamsung devices always seem to have memory issues.
 
Upvote 0

brodmuehler

Member
Licensed User
Longtime User
I recommend you to switch to TableView. It should handle it easily.
Hallo Erel. Thanks for the prompt reply Since I have quite a number of columns, is the tableview able to scroll horizontally? I remember some comments I read when I decided to use the WebView that the TableView cannot scoll ledt and right. Rene
 
Upvote 0

brodmuehler

Member
Licensed User
Longtime User
or there's Scrollview2d
Hallo....thanks everybody for the great support. I tried to find the Scrollview2d and FlexibleTable libraries but I am doing something wrong. Could you please advise where I can find them or what I have to do to use these views and how I use them in my app. I downloaded the examples but hey are also looking for the scrollview2d library. I have to admit I am lost a bit. Sorry!
 
Upvote 0
Top