Android Question Heap Size

buras3

Active Member
Licensed User
hey

my bug is java.lang.OutOfMemoryError: bitmap size exceeds VM budget(Heap Size=18695KB, Allocated=14308KB, Bitmap Size=11730KB)

in android >3 it's ok
but in my other device i get this error in
B4X:
'Converts a bytes array to an image (for BLOB fields).
Public Sub BytesToImage(bytes() As Byte) As Bitmap
   Dim In As InputStream
   In.InitializeFromBytesArray(bytes, 0, bytes.Length)
   Dim bmp As Bitmap
   bmp.Initialize2(In )
   Return bmp
End Sub
my questions are:
1 is the size is too big - am i doing something wrong? the bmp is 2-3 mega not 11 mega
2 can i get the heap size and Allocated for the device and reduce the bytes array ?

the only solution for now is to reduce the bmp before upload - but then the quality is not good

tank you all
 

buras3

Active Member
Licensed User
Sure, usually I do.

I was using service with reqManager to download Images from sql server - "select * from PicTable" (about 10 images)
I Changed to "select * from PicTable where PicId=?"
and downloaded the images one at the time
the idea came from one of Erel posts - that the memory will be free when the object is released
 
Last edited:
Top