Hi guys,
Just want to give another angle to it... which was successfully run & tested. Yesterday while streaming video cam images { through socket - getting bitmaps at a good refresh rate} we where getting this nasty Out of memory error and as one the posting suggested to recycle the bitmaps which are not drawn. But, our problem was that we are drawing the same bitmap again & again in the draw() method so how can we recycle the bitmap. Moreover, even if we use the same bitmap again & again the memory steeply increases eventually throwing out of Memory. So, here's the deal * Make Bitmap Buffer array: In my case I made an array of 10. * Take a circular say 'display pointer' which would run through the buffered array: * Take another circular 'freeing pointer' which would run at a fixed distance back of the 'display pointer' * Job of the display pointer would be to setBitmap, displayBitmap & draw It. * Whereas the freeing pointer which would be back of it exactly at a fixed distance (ex: 5) behind it would be recycling all the bitmaps which are not used * Thus, at any given point of time we would always have ample free memory space and the bitmaps used at any given point of time would be absolute difference between { display counter pointer - freeing pointer counter } - making an endless 'rat race'. Though we are using 5-10 bitmaps in place of one, but believe me it doesn't give you that nasty Out of memory error Now this approach we have applied & not got the OOM error yet, but the initial crude test can be done by our test manager when she arrives today �� let me know, if anybody needs the full code of it or a snippet of it.... Thanks, Catalytic Android team On Feb 5, 12:14 am, Romain Guy <romain...@google.com> wrote: > Use less memory. > > > > On Wed, Feb 4, 2009 at 11:11 AM, Rohit <mord...@gmail.com> wrote: > > > So whats a good solution? > > > Rohit > > > On Feb 4, 11:07 am, Romain Guy <romain...@google.com> wrote: > >> Scaling the image down happens at drawing time. You are just using > >> images that are too large to begin with. > > >> On Wed, Feb 4, 2009 at 11:05 AM, Rohit <mord...@gmail.com> wrote: > > >> > I noticed that the OutOfMemoryError occurs a lot when you try to load > >> > an image that is larger than the view. Android needs to scale the > >> > image down to fit the view and that is when it seems to crash out as a > >> > result of the OutOfMemoryError. > > >> > Rohit > > >> > On Jan 26, 3:09 pm, blindfold <seeingwithso...@gmail.com> wrote: > >> >> > Check first, and think a bit. > > >> >> I stand by what I said. > > >> >> Regards > > >> >> On Jan 25, 8:30 pm, ad <avra...@gmail.com> wrote: > > >> >> > Check first, and think a bit. > > >> >> > On Jan 25, 2:49 pm, blindfold <seeingwithso...@gmail.com> wrote: > > >> >> > > How can this possibly help you? You are trying to allocate 61 MB > >> >> > > (3200*4800*4 bytes), which lies well above the 16 MB heap limit. I > >> >> > > tried once to allocate, say, 12 MB at program startup to keep > >> >> > > Android > >> >> > > from all the time bumping into the heap limit and possibly crashing > >> >> > > as > >> >> > > a result in case its memory management is not 100% reliable, but > >> >> > > trying to allocate 61 MB should not offer any benefit? > > >> >> > > Regards > > >> >> > > On Jan 25, 2:23 pm, ad <avra...@gmail.com> wrote: > > >> >> > > > YES YES YES!!! > >> >> > > > I've found solution for that bug. > >> >> > > > It's tricky but it works. > >> >> > > > Place that on the begining of your code. > > >> >> > > > try{ > >> >> > > > BitmaptmpBitmap > >> >> > > > =Bitmap.createBitmap > >> >> > > > (3200, 4800, > >> >> > > > Config.ARGB_8888); > >> >> > > > }catch(Throwable e){ > >> >> > > > e.printStackTrace(); > >> >> > > > System.out.println("CATCHED !!!!"); > > >> >> > > > } > > >> >> > > > I was fighting with that about 4 days. > >> >> > > > Hope anyone is happy now, that was hell. > > >> >> > > > Regards, > >> >> > > > avram. > > >> -- > >> Romain Guy > >> Android framework engineer > >> romain...@android.com > > >> Note: please don't send private questions to me, as I don't have time > >> to provide private support. All such questions should be posted on > >> public forums, where I and others can see and answer them > > -- > Romain Guy > Android framework engineer > romain...@android.com > > Note: please don't send private questions to me, as I don't have time > to provide private support. All such questions should be posted on > public forums, where I and others can see and answer them --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---