Android Question Graph - java.lang.OutOfMemoryError

DT1111

Member
Licensed User
Longtime User
I have the java.lang.OutOfMemoryError when my app runs on an Android mini pc which has 1 GB RAM but doesn't have any problem when running on a smartphone which has less RAM. Both have 4.4.2 Android OS. But the Android mini pc is connected to a large TV screen though. Not sure if this makes the app consumes more memory.

The graphing sub uses the Android chart framework.

The following is the error log

B4X:
charts_drawlinechart (B4A line: 1032)
LD.Canvas.Initialize(LD.Target)
java.lang.OutOfMemoryError
    at android.graphics.Bitmap.nativeCreate(Native Method)
    at android.graphics.Bitmap.createBitmap(Bitmap.java:813)
    at android.graphics.Bitmap.createBitmap(Bitmap.java:790)
    at android.graphics.Bitmap.createBitmap(Bitmap.java:757)
    at anywheresoftware.b4a.objects.drawable.CanvasWrapper.Initialize(CanvasWrapper.java:76)
    at graph.app.charts._drawlinechart(charts.java:1260)
    at graph.app.main._plotgraph(main.java:11338)
    at graph.app.main._load_data(main.java:9805)
    at graph.app.main._activity_create(main.java:1399)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:187)
    at graph.app.main.afterFirstLayout(main.java:102)
    at graph.app.main.access$000(main.java:17)
    at graph.app.main$WaitForLayout.run(main.java:80)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5017)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:788)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:604)
    at dalvik.system.NativeStart.main(Native Method)

I am not sure if this is a hardware issue with the Android mini PC connected to a large screen.

Any help is appreciated. Thank you.
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
what are the dimensions of the tv-screen/canvas?
 
Upvote 0

DT1111

Member
Licensed User
Longtime User
Hi DonManFred

The screen dimension is 1920 x 1008 (scale 1.5) and when normalized to scale 1.0, the dimension is 1280 x 672. I think the canvas is not overly large, is it?

If that is the root cause, is there a solution? Thanks.
 
Upvote 0

DT1111

Member
Licensed User
Longtime User
Hi Roycefer

That solved the memory problem. Thank you! Are there any known trade-offs in increasing the heap memory?
 
Last edited:
Upvote 0

Roycefer

Well-Known Member
Licensed User
Longtime User
Not that I know of. I suppose if your app uses a large heap, it might be one of the first to be killed off by the OS when the OS needs more memory. But this is pure speculation. And even if it's true, it doesn't seem like that big of a deal.
 
Upvote 0
Top