Strange Memory Error

Smee

Well-Known Member
Licensed User
Longtime User
I have installed an app to a xoom and during testing i open a new activity screen and close it multiple times. On one tablet it works fine no matter how many times i do it but on another after 3 goes back and forward i get a memory error. There is no major bitmaps loaded except for the screen background but it works fine on one device and crashes on another.

Is it possible to have bad memory chips? The one causing a problem is a brand new device!!!!

B4X:
** Activity (main) Pause, UserClosed = false **
** Activity (maintenance) Create, isFirst = true **
GC_FOR_ALLOC freed 7754K, 46% free 21414K/39175K, paused 30ms
Forcing collection of SoftReferences for 12030352-byte allocation
GC_BEFORE_OOM freed 20K, 46% free 21393K/39175K, paused 29ms
Out of memory on a 12030352-byte allocation.
"main" prio=5 tid=1 RUNNABLE
  | group="main" sCount=0 dsCount=0 obj=0x401975c8 self=0x125f8
  | sysTid=3313 nice=0 sched=0/0 cgrp=default handle=-1342909336
  | schedstat=( 6611614000 713838000 4433 ) utm=571 stm=90 core=0
  at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
  at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:483)
  at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:549)
  at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize2(CanvasWrapper.java:493)
  at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize(CanvasWrapper.java:486)
  at WDROrder.Program.maintenance._activity_create(maintenance.java:244)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:491)
  at anywheresoftware.b4a.BA.raiseEvent2(BA.java:105)
  at WDROrder.Program.maintenance.afterFirstLayout(maintenance.java:84)
  at WDROrder.Program.maintenance.access$100(maintenance.java:16)
  at WDROrder.Program.maintenance$WaitForLayout.run(maintenance.java:72)
  at android.os.Handler.handleCallback(Handler.java:587)
  at android.os.Handler.dispatchMessage(Handler.java:92)
  at android.os.Looper.loop(Looper.java:132)
  at android.app.ActivityThread.main(ActivityThread.java:4157)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:491)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
  at dalvik.system.NativeStart.main(Native Method)
libjpeg error 105 <  Ss=%d, Se=%d, Ah=%d, Al=%d> from allocPixelRef [2832 2124]
--- decoder->decode returned false
Shutting down VM
threadid=1: thread exiting with uncaught exception (group=0x40190760)
FATAL EXCEPTION: main
java.lang.OutOfMemoryError
   at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
   at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:483)
   at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:549)
 

Smee

Well-Known Member
Licensed User
Longtime User
Thanks for the fast reply Erel,

I have changed the code from
B4X:
NewBitmap1.Initialize(File.DirAssets,"menu2.jpg")
pnlMaintenance.SetBackgroundImage(NewBitmap1)

to this

B4X:
Activity.SetBackgroundImage(LoadBitmapSample(File.DirAssets, "menu2.jpg", Activity.Width, Activity.Height))

However the background does not show. Am i missing something here?


OOOOpppsss

I noticed.

It should have been


pnlMaintenance..SetBackgroundImage

Thank you, that seems to have fixed that problem. Now to the next
 
Last edited:
Upvote 0
Top