java.lang.OutOfMemoryError: bitmap size exceeds VM budget

mhartwig

Member
Licensed User
Longtime User
I am getting this problem and i pretty sure it is in this section. Wierd thing is, I am only now getting with when I put CyanogenMod on the phone. When my phone was vanilla, had no problems at all.

I think it is this code block that is causing it:
B4X:
'Executes the query and fills the ListView with the value.
'If TwoLines is true then the first column is mapped to the first line and the second column is mapped
'to the second line.
'In both cases the value set to the row is the array with all the records values.
Sub ExecuteListView(SQL As SQL, Query As String, StringArgs() As String, Limit As Int, ListView1 As ListView, _
   TwoLines As Boolean, Bitmap As Boolean)
   ListView1.Clear
   Dim Table As List
   Table = ExecuteMemoryTable(SQL, Query, StringArgs, Limit)
   Dim Cols() As String
   For i = 0 To Table.Size - 1
      Cols = Table.Get(i)
      If TwoLines Then
         ListView1.AddTwoLines2(Cols(0), Cols(1), Cols)
      Else
         If Bitmap = False Then
            ListView1.AddSingleLine2(Cols(0), Cols)
         End If
      End If
      
      If Bitmap Then
         Dim bmp As Bitmap
         Dim su As StringUtils
         Dim bt() As Byte
         bt = su.DecodeBase64(Cols(6))
         Dim inp As InputStream
         inp.InitializeFromBytesArray(bt, 0, bt.Length)
         bmp.Initialize2(inp)
         ListView1.AddTwoLinesAndBitmap2(Cols(0), Cols(2), bmp, Cols)
      End If
   Next
End Sub

Specifically the part with the byte array.
 

mhartwig

Member
Licensed User
Longtime User
I figured it out. I scaled the bitmaps down a little, but the real fix was with cyanogenmod. It has the vm heap size set to default at 32. Scaled it up to 48, which is what it normally should be.
 
Upvote 0
Top