Android Question .

agraham

Expert
Licensed User
Longtime User
As is usual with out of memory errors it appears to be Bitmap related and in Activity_Create when creating a Bitmap from an Asset file during LoadLayout.
at anywheresoftware.b4a.objects.ActivityWrapper.LoadL ayout(ActivityWrapper.java:190)
at slifkergames.com_poker_dealers_toolkit.main._activ ity_create(main.java:2450)
...
Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
I am very very rusty on Android UI but I don't see why this is happening unless you have some very large Bitmaps on some of your views. I would have expected Android to properly manage Bitmaps on views for itself so I 'm a bit puzzled unless your layout memory usage is pushing close to the VM memory budget.
 
Upvote 0

melamoud

Active Member
Licensed User
Longtime User
I do not have your entire projecxt so I'm guessing,
loadlayout does not know how to handle bitmaps properly it use loadBitmap instead of loadbitmapsample, this is , in many cases the problem
I suggest you erasall your bitmap usages in the designer and load it manually in code user loadBitmapSample, and put the right maxwidth and maxheight

the reason it happen the next time you run it is because the app alreday in memory and you try to load images again - you might need to clean the images manually when you pause your activity (or when you create not for the first time)

I suspect the reason you get your DB corrupted is because you are not using transactions and you crush in the middle of complex writing to the DB (more than one update/insert that leave the DB incorrect if you stop in the middle), try to log before and after any DB write opperation see if this is true
 
Upvote 0

melamoud

Active Member
Licensed User
Longtime User
still,

I was surprise as well, but , at least , for me it worked out,
I had less images than you BTW.

try it.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I think that there are two unrelated issues here:

There is an out of memory error that happens when the layout is loaded. You should check the dimensions of your images and make sure that they are not too large. The compressed size (PNG) is less important.

About the null pointer error. Does it happen when the activity is paused or when you press a button?

The logs show that the error happens in Activity_Pause.

(note that it is better to upload the logs as a text file for such large logs)
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
The number of variables should not matter. You should make sure that you are not creating unnecessary large objects (such as bitmaps).

See this tutorial for more information about the activities life cycle: Android Process and activities life cycle

Objects are released by the garbage collector when there are no more live references to them.

I think that the OS library includes a method to find the available memory.
 
Upvote 0
Top