Re: [android-developers] Re: Handling Bitmap Out of Memory Error

2012-07-17 Thread Francisco M. Marzoa Alonso
:-X

On Jul 17, 2012 10:29 AM, "Ralph Bergmann | the4thFloor.eu" <
ra...@the4thfloor.eu> wrote:
>
> Am 17.07.12 09:22, schrieb Francisco M. Marzoa Alonso:
> > GC does NOT take care of recycling Bitmaps, so the answer is that YOU
> > should do that.
>
> public void recycle ()
>
> ... This is an advanced call, and normally need not be called, since the
> normal GC process will free up this memory when there are no more
> references to this bitmap.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: Handling Bitmap Out of Memory Error

2012-07-17 Thread Ralph Bergmann | the4thFloor.eu
Am 17.07.12 09:22, schrieb Francisco M. Marzoa Alonso:
> GC does NOT take care of recycling Bitmaps, so the answer is that YOU
> should do that.

public void recycle ()

... This is an advanced call, and normally need not be called, since the
normal GC process will free up this memory when there are no more
references to this bitmap.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: Handling Bitmap Out of Memory Error

2012-07-17 Thread Francisco M. Marzoa Alonso
GC does NOT take care of recycling Bitmaps, so the answer is that YOU
should do that.
On Jul 17, 2012 9:16 AM, "B.Arunkumar"  wrote:

> Hi,
>
>We are using 640*480 resolution video frames with frame rate of 10
> frames/sec. Another question related to bitmaps is do we really need
> to recycle bitmaps or can we assume that the Garbage Collector would
> take care of disposing bitmaps?
>
> Thank you,
> B.Arunkumar
>
> On Jul 17, 6:49 am, "Francisco M. Marzoa Alonso" 
> wrote:
> > Hi,
> >
> > I bet that Motorola has android 2.1 or 2.1.-update1
> >
> > I'm fed up of OOM problems with these, and have not found a solution
> > after lot of tries, including changing several bitmaps by graphic
> > primitives drawn on the fly to use less memory, so I just assumed that
> > there is something I must live with.
> >
> > On the other hand, at least in my cases and I think in most of the
> > cases, if you cannot load these bitmaps your application cannot work
> > properly, so there is no way of handling such situation that may be
> > better than the crash itself.
> >
> > Anyway your bitmap seems to be too big. What resolution are you using?
> > SGSII has 800x480 pixels, that means that you need about to 1536000
> > bytes for storing a full screen bitmap as ARGB_, but you are
> > requesting more than the double, a waste of space. And if you are doing
> > the same with several bitmaps, it is A LOT of wasted memory.
> >
> > Regards,
> >
> > On 16/07/12 14:23,B.Arunkumarwrote:
> >
> >
> >
> >
> >
> >
> >
> > > Hi,
> >
> > >We have an app which renders bitmaps on imageview. On Samsung
> > > Galaxy, it works fine. But On Motorola Droid, it runs into memory
> > > issues and crashes every now and then with the following logcat.
> >
> > > /dalvikvm-heap( 3640): 3686400-byte external allocation too large for
> > > this process.
> > > E/GraphicsJNI( 3640): VM won't let us allocate 3686400 bytes
> > > W/dalvikvm( 3640): threadid=11: thread exiting with uncaught exception
> > > (group=0x4001d7e0)
> > > E/AndroidRuntime( 3640): FATAL EXCEPTION: Thread-25
> > > E/AndroidRuntime( 3640): java.lang.OutOfMemoryError: bitmap size
> > > exceeds VM budget
> > > E/AndroidRuntime( 3640):   at
> > > android.graphics.Bitmap.nativeCreate(Native Method)
> > > E/AndroidRuntime( 3640):   at
> > > android.graphics.Bitmap.createBitmap(Bitmap.java:468)
> > > E/AndroidRuntime( 3640):   at
> > > com.example.OnVRViewer.RTPClient.ProcessFrame(RTPClient.java:419)
> > > E/AndroidRuntime( 3640):   at
> > > com.example.OnVRViewer.RTPClient.ProcessRtpVideoPacket(RTPClient.java:
> > > 204)
> > > E/AndroidRuntime( 3640):   at
> > > com.example.OnVRViewer.RTSPUDPclient.AdvanceProcess(RTSPUDPclient.java:
> > > 659)
> > > E/AndroidRuntime( 3640):   at
> > >
> com.example.OnVRViewer.RTSPUDPclient.processSelectionKey(RTSPUDPclient.java:
> > > 726)
> > > E/AndroidRuntime( 3640):   at
> > > com.example.OnVRViewer.RTSPUDPclient.run(RTSPUDPclient.java:2068)
> > > E/AndroidRuntime( 3640):   at java.lang.Thread.run(Thread.java:1096)
> > > W/ActivityManager( 1081):   Force finishing activity
> > > com.example.OnVRViewer/.AsyncRecordTrial
> >
> > > My question is even though we have a try catch on Bitmap.createBitmap
> > > it is still crashing. Why is the catch block not working? And how do
> > > we handle the exception without crashing on Motorola Droid.
> >
> > > Following is my code right now:
> >
> > > try
> > > {
> > >bm = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_);
> > > }
> > > catch (Exception ex)
> > > {
> > >android.util.Log.e("Bitmap", "Error");
> > > }
> >
> > > Thank you,
> > >B.Arunkumar
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en