how debug a memory error?

melamoud

Active Member
Licensed User
Longtime User
trying to debug an out of memory I have, need some help with the tools avilable

I have a service that fetch xml pages from the internet one at a time , parse the results and put it in a db.

I maintain few lists that does not grow much, so it should not be the problem
I get out of memory after a whle (before the end of the scan)

in order to debug it I need at least
1. way to log amount of free memory on the phone
2. way to log amount of memory used by my process

any idea how to get that info ?

any other ideas of tools to help me narrow down the issue ?
thanks
 

melamoud

Active Member
Licensed User
Longtime User
is not always the same, and not always at the same time (as in most cases of memory issues) but here it is
B4X:
06:41:50 MNot:Activity Create:06:41:50 FirstTime=false
06:41:52 MNot:init slide menu


slidemenu_additem (java line: 103)


java.lang.OutOfMemoryError: bitmap size exceeds VM budget


   at android.graphics.Bitmap.nativeCreate(Native Method)
   at android.graphics.Bitmap.createBitmap(Bitmap.java:507)
   at anywheresoftware.b4a.objects.drawable.CanvasWrapper.Initialize(CanvasWrapper.java:72)
   at appsright.musicnotifier.slidemenu._additem(slidemenu.java:103)
   at appsright.musicnotifier.main._activity_create(main.java:343)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
   at appsright.musicnotifier.main.afterFirstLayout(main.java:89)
   at appsright.musicnotifier.main.access$100(main.java:16)
   at appsright.musicnotifier.main$WaitForLayout.run(main.java:74)
   at android.os.Handler.handleCallback(Handler.java:587)
   at android.os.Handler.dispatchMessage(Handler.java:92)
   at android.os.Looper.loop(Looper.java:130)
   at android.app.ActivityThread.main(ActivityThread.java:3806)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
   at dalvik.system.NativeStart.main(Native Method)


and this is after app is sleeped for 12 hours (no activity on phone)
the images on the slide menu are small (5K) I have other pictures not related to slide menu that each can be 160K

nir
 
Upvote 0

melamoud

Active Member
Licensed User
Longtime User
Most memory issues are related to images. Can you post the code in SlideMenu.AddItem ?

sure here it is:
B4X:
Public Sub AddItem(Text As String, Image As Bitmap, ReturnValue As Object, tag As Int)
   Utilities.LogM(0,"Add Item has been called:" & Text & " tag=" & tag & " Value="& ReturnValue)
   Dim item As ActionItem
   item.Initialize
   item.Text = Text
   item.Image = Image
   item.Value = ReturnValue
   item.tag = tag
   
   If Not(Image.IsInitialized) Then
      If (showNoImageToLeft) Then
         mListView.AddTwoLines2(Text,"",item)
      Else
         mListView.AddTwoLinesAndBitmap2(Text, "", Null, item)      
      End If
   Else
      Utilities.LogM(0,"has image of h=" & Image.Height & " w=" & Image.Width)
      mListView.AddTwoLinesAndBitmap2(Text, "", Image, item)
      hasImage = True
   End If
   'Log (mListView.Size & " items Hight:" & (mListView.Size * itemHeight))
            
   'mSlidePanel.Height = mListView.Size * itemHeight - 2
   'If (mSlidePanel.Height > 100%y - mSlidePanel.Top) Then mSlidePanel.Height = 100%y - mSlidePanel.Top

   mSlidePanel.Height = mListView.Size * itemHeight - 2   
   If (mSlidePanel.Height > 100%y) Then mSlidePanel.Height = 100%y
   mSlidePanel.Top = 100%y-mSlidePanel.Height ' set to grow from the bottom      
   mListView.Height = mSlidePanel.Height 
   'log ("width=" & mlistView.Width)
   Dim c As Canvas
   c.Initialize(mListView)
   Dim w As Int = c.MeasureStringWidth(Text,mListView.TwoLinesAndBitmap.Label.Typeface,mListView.TwoLinesAndBitmap.Label.TextSize) + mListView.TwoLinesAndBitmap.Label.Left+ 10
   'Log ("w=" & w)
   If (w>100%x) Then w = 100%x
   If (w > mSlidePanel.Width ) Then ' if smaller no need to change, leave the width as the wider of all labels
      'Log ("setting width to be:" & w)
      mSlidePanel.Width = w
      mListView.Width = w      
   End If   
End Sub

thanks

and here is the issue again now with more details (were not there before)
B4X:
08:41:57 MNot:Activity Create:08:41:57 FirstTime=false



java.lang.reflect.InvocationTargetException
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:19)
   at anywheresoftware.b4a.objects.drawable.StateListDrawable.build(StateListDrawable.java:72)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:19)
   at anywheresoftware.b4a.objects.ButtonWrapper.build(ButtonWrapper.java:87)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:19)
   at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:233)
   at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:273)
   at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:123)


   at anywheresoftware.b4a.objects.PanelWrapper.LoadLayout(PanelWrapper.java:106)
   at appsright.musicnotifier.main._activity_create(main.java:277)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
   at appsright.musicnotifier.main.afterFirstLayout(main.java:89)
   at appsright.musicnotifier.main.access$100(main.java:16)
   at appsright.musicnotifier.main$WaitForLayout.run(main.java:74)
   at android.os.Handler.handleCallback(Handler.java:587)
   at android.os.Handler.dispatchMessage(Handler.java:92)
   at android.os.Looper.loop(Looper.java:130)
   at android.app.ActivityThread.main(ActivityThread.java:3806)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
   at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
   at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
   at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
   at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:525)
   at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize2(CanvasWrapper.java:498)
   at anywheresoftware.b4a.objects.drawable.BitmapDrawable.build(BitmapDrawable.java:74)
   ... 31 more



java.lang.reflect.InvocationTargetException
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:19)
   at anywheresoftware.b4a.objects.drawable.StateListDrawable.build(StateListDrawable.java:72)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:19)
   at anywheresoftware.b4a.objects.ButtonWrapper.build(ButtonWrapper.java:87)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:19)
   at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:233)
   at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:273)
   at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:123)


   at anywheresoftware.b4a.objects.PanelWrapper.LoadLayout(PanelWrapper.java:106)
   at appsright.musicnotifier.main._activity_create(main.java:277)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
   at appsright.musicnotifier.main.afterFirstLayout(main.java:89)
   at appsright.musicnotifier.main.access$100(main.java:16)
   at appsright.musicnotifier.main$WaitForLayout.run(main.java:74)
   at android.os.Handler.handleCallback(Handler.java:587)
   at android.os.Handler.dispatchMessage(Handler.java:92)
   at android.os.Looper.loop(Looper.java:130)
   at android.app.ActivityThread.main(ActivityThread.java:3806)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
   at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
   at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
   at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
   at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:525)
   at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize2(CanvasWrapper.java:498)
   at anywheresoftware.b4a.objects.drawable.BitmapDrawable.build(BitmapDrawable.java:74)
   ... 31 more



java.lang.reflect.InvocationTargetException
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:19)
   at anywheresoftware.b4a.objects.drawable.StateListDrawable.build(StateListDrawable.java:72)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:19)
   at anywheresoftware.b4a.objects.ButtonWrapper.build(ButtonWrapper.java:87)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:19)
   at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:233)
   at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:273)
   at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:123)


   at anywheresoftware.b4a.objects.PanelWrapper.LoadLayout(PanelWrapper.java:106)
   at appsright.musicnotifier.main._activity_create(main.java:277)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
   at appsright.musicnotifier.main.afterFirstLayout(main.java:89)
   at appsright.musicnotifier.main.access$100(main.java:16)
   at appsright.musicnotifier.main$WaitForLayout.run(main.java:74)
   at android.os.Handler.handleCallback(Handler.java:587)
   at android.os.Handler.dispatchMessage(Handler.java:92)
   at android.os.Looper.loop(Looper.java:130)
   at android.app.ActivityThread.main(ActivityThread.java:3806)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
   at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
   at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
   at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
   at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:525)
   at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize2(CanvasWrapper.java:498)
   at anywheresoftware.b4a.objects.drawable.BitmapDrawable.build(BitmapDrawable.java:74)
   ... 31 more



java.lang.reflect.InvocationTargetException
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:19)
   at anywheresoftware.b4a.objects.drawable.StateListDrawable.build(StateListDrawable.java:72)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:19)
   at anywheresoftware.b4a.objects.ButtonWrapper.build(ButtonWrapper.java:87)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:19)
   at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:233)
   at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:273)
   at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:123)


   at anywheresoftware.b4a.objects.PanelWrapper.LoadLayout(PanelWrapper.java:106)
   at appsright.musicnotifier.main._activity_create(main.java:277)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
   at appsright.musicnotifier.main.afterFirstLayout(main.java:89)
   at appsright.musicnotifier.main.access$100(main.java:16)
   at appsright.musicnotifier.main$WaitForLayout.run(main.java:74)
   at android.os.Handler.handleCallback(Handler.java:587)
   at android.os.Handler.dispatchMessage(Handler.java:92)
   at android.os.Looper.loop(Looper.java:130)
   at android.app.ActivityThread.main(ActivityThread.java:3806)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
   at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
   at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
   at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
   at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:525)
   at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize2(CanvasWrapper.java:498)
   at anywheresoftware.b4a.objects.drawable.BitmapDrawable.build(BitmapDrawable.java:74)
   ... 31 more



java.lang.reflect.InvocationTargetException
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:19)
   at anywheresoftware.b4a.objects.drawable.StateListDrawable.build(StateListDrawable.java:72)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:19)
   at anywheresoftware.b4a.objects.ButtonWrapper.build(ButtonWrapper.java:87)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:19)
   at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:233)
   at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:273)
   at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:123)


   at anywheresoftware.b4a.objects.PanelWrapper.LoadLayout(PanelWrapper.java:106)
   at appsright.musicnotifier.main._activity_create(main.java:277)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
   at appsright.musicnotifier.main.afterFirstLayout(main.java:89)
   at appsright.musicnotifier.main.access$100(main.java:16)
   at appsright.musicnotifier.main$WaitForLayout.run(main.java:74)
   at android.os.Handler.handleCallback(Handler.java:587)
   at android.os.Handler.dispatchMessage(Handler.java:92)
   at android.os.Looper.loop(Looper.java:130)
   at android.app.ActivityThread.main(ActivityThread.java:3806)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
   at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
   at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
   at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
   at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:525)
   at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize2(CanvasWrapper.java:498)
   at anywheresoftware.b4a.objects.drawable.BitmapDrawable.build(BitmapDrawable.java:74)
   ... 31 more



java.lang.reflect.InvocationTargetException
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:19)
   at anywheresoftware.b4a.objects.drawable.StateListDrawable.build(StateListDrawable.java:72)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:19)
   at anywheresoftware.b4a.objects.ButtonWrapper.build(ButtonWrapper.java:87)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:19)
   at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:233)
   at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:273)
   at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:123)


   at anywheresoftware.b4a.objects.PanelWrapper.LoadLayout(PanelWrapper.java:106)
   at appsright.musicnotifier.main._activity_create(main.java:277)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
   at appsright.musicnotifier.main.afterFirstLayout(main.java:89)
   at appsright.musicnotifier.main.access$100(main.java:16)
   at appsright.musicnotifier.main$WaitForLayout.run(main.java:74)
   at android.os.Handler.handleCallback(Handler.java:587)
   at android.os.Handler.dispatchMessage(Handler.java:92)
   at android.os.Looper.loop(Looper.java:130)
   at android.app.ActivityThread.main(ActivityThread.java:3806)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
   at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
   at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
   at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
   at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:525)
   at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize2(CanvasWrapper.java:498)
   at anywheresoftware.b4a.objects.drawable.BitmapDrawable.build(BitmapDrawable.java:74)
   ... 31 more



java.lang.reflect.InvocationTargetException
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:19)
   at anywheresoftware.b4a.objects.drawable.StateListDrawable.build(StateListDrawable.java:72)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:19)
   at anywheresoftware.b4a.objects.ButtonWrapper.build(ButtonWrapper.java:87)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:19)
   at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:233)
   at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:273)
   at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:123)


   at anywheresoftware.b4a.objects.PanelWrapper.LoadLayout(PanelWrapper.java:106)
   at appsright.musicnotifier.main._activity_create(main.java:277)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
   at appsright.musicnotifier.main.afterFirstLayout(main.java:89)
   at appsright.musicnotifier.main.access$100(main.java:16)
   at appsright.musicnotifier.main$WaitForLayout.run(main.java:74)
   at android.os.Handler.handleCallback(Handler.java:587)
   at android.os.Handler.dispatchMessage(Handler.java:92)
   at android.os.Looper.loop(Looper.java:130)
   at android.app.ActivityThread.main(ActivityThread.java:3806)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
   at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
   at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
   at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
   at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:525)
   at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize2(CanvasWrapper.java:498)
   at anywheresoftware.b4a.objects.drawable.BitmapDrawable.build(BitmapDrawable.java:74)
   ... 31 more



java.lang.reflect.InvocationTargetException
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:19)
   at anywheresoftware.b4a.objects.drawable.StateListDrawable.build(StateListDrawable.java:72)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:19)
   at anywheresoftware.b4a.objects.ButtonWrapper.build(ButtonWrapper.java:87)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:19)
   at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:233)
   at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:273)
   at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:123)


   at anywheresoftware.b4a.objects.PanelWrapper.LoadLayout(PanelWrapper.java:106)
   at appsright.musicnotifier.main._activity_create(main.java:277)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
   at appsright.musicnotifier.main.afterFirstLayout(main.java:89)
   at appsright.musicnotifier.main.access$100(main.java:16)
   at appsright.musicnotifier.main$WaitForLayout.run(main.java:74)
   at android.os.Handler.handleCallback(Handler.java:587)
   at android.os.Handler.dispatchMessage(Handler.java:92)
   at android.os.Looper.loop(Looper.java:130)
   at android.app.ActivityThread.main(ActivityThread.java:3806)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
   at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
   at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
   at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
   at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:525)
   at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize2(CanvasWrapper.java:498)
   at anywheresoftware.b4a.objects.drawable.BitmapDrawable.build(BitmapDrawable.java:74)
   ... 31 more
08:42:00 MNot:init slide menu


main_activity_create (java line: 335)


java.lang.OutOfMemoryError: bitmap size exceeds VM budget


   at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
   at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
   at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.InitializeSample(CanvasWrapper.java:525)
   at anywheresoftware.b4a.keywords.Common.LoadBitmapSample(Common.java:1040)
   at appsright.musicnotifier.main._activity_create(main.java:335)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
   at appsright.musicnotifier.main.afterFirstLayout(main.java:89)
   at appsright.musicnotifier.main.access$100(main.java:16)
   at appsright.musicnotifier.main$WaitForLayout.run(main.java:74)
   at android.os.Handler.handleCallback(Handler.java:587)
   at android.os.Handler.dispatchMessage(Handler.java:92)
   at android.os.Looper.loop(Looper.java:130)
   at android.app.ActivityThread.main(ActivityThread.java:3806)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
   at dalvik.system.NativeStart.main(Native Method)
 
Upvote 0

melamoud

Active Member
Licensed User
Longtime User
Try to remove these lines:
B4X:
Dim c As Canvas
c.Initialize(mListView)
It is not efficient to create a new canvas each time. You should instead create a single global canvas and reuse it.

fair point, but can that cause it ?
 
Upvote 0

melamoud

Active Member
Licensed User
Longtime User
I only have 6 items in the menu and I init only when app is created

so how much more that 6 spare canvases shoudl take compare to the list and the images etc ? enoght to kill the app ?
 
Upvote 0

melamoud

Active Member
Licensed User
Longtime User
no its now happened again (one canvas), and I think I know how to reproduce it,

if I exit the app (back button) while it is working (httpJOB running inside a serivce)
and start the app again , as soon as I call that slide menu additem it gets out of memory

it also happened in the past without me exit the app, but maybe the phone did killed it or paused it.

any idea ?
 
Upvote 0

melamoud

Active Member
Licensed User
Longtime User
It might be I have only one large image set as background so it will be large dimension

But why this is happening mainly (not only) when I exit the app and start it again fast (almost every time)
 
Upvote 0
Top