There best working approach is to only load Bounds of the image, and
then use scale to load the Bitmap of the needed size.
This way you never load the full-size bitmap in the memory.

http://code.google.com/intl/ja/android/reference/android/graphics/BitmapFactory.Options.html#inJustDecodeBounds

get the bounds, and then use those to calculate the appropriate sample
size.



On Feb 26, 2:36 pm, mark.ka...@gmail.com wrote:
>   I'm just saying there have been a number of threads on this issue,
> I've had out of memory problems when processing bitmaps, and so have
> many other developers. It looks to me like a bug IMHO. I hope this
> problem will be resolved at some point.
>
> On Feb 26, 2:02 pm, "bra...@gmail.com" <peacoc...@gmail.com> wrote:
>
> > If that is the case then why does calling myBitmap.recycle not give me
> > that memory back to use for the next time I go into an edit.
>
> > On Feb 26, 4:59 pm, Romain Guy <romain...@google.com> wrote:
>
> > > BitmapFactory does NOT leak Bitmaps.
>
> > > A 2056x1536 opaque image requires 6 MB of RAM. An application has 16
> > > MB max. Do the math.
>
> > > On Thu, Feb 26, 2009 at 1:50 PM,  <mark.ka...@gmail.com> wrote:
>
> > > >  Are you using BitmapFactory? There have been a number of threads
> > > > about memory leaks, or similar problems when using BitmapFactory to
> > > > process bitmaps. Using Bitmap.recycle may mitigate, but not eliminate
> > > > these types of problems.
>
> > > >                 M
>
> > > > On Feb 26, 11:39 am, Mattaku Betsujin <mattaku.betsu...@gmail.com>
> > > > wrote:
> > > >> I think the best solution to handle very large bitmaps is to be able to
> > > >> decode only a small chunk of the bitmap at a time and process it.
>
> > > >> Does anyone know if the existing Android API can support this?
>
> > > >> If not, probably one solution is to write a smart decoder (in Java, so 
> > > >> slow
> > > >> :-( ....)  that can decode a small chunk.
>
> > > >> On Thu, Feb 26, 2009 at 11:32 AM, Tomei Ningen 
> > > >> <tomei.nin...@yahoo.com>wrote:
>
> > > >> > You're running into memory fragmentation problems. Bitmap memory is
> > > >> > not allocated from the Java object heap. Instead, it's allocated from
> > > >> > the 'malloc' heap. That's why you don't see the Java heap expanding.
>
> > > >> > How big is your bitmap? If you're processing JPEG files, probably it
> > > >> > will be better to read the thumbnail directly from the JPEG file. 
> > > >> > This
> > > >> > way you don't need to create the Bitmap at all.
>
> > > >> > On Feb 26, 9:47 am, "bra...@gmail.com" <peacoc...@gmail.com> wrote:
> > > >> > > Ok I am at the end of my rope.
>
> > > >> > > I am doing some image processing. I have a large image file which I
> > > >> > > open and create a smaller bitmap from. At the end of processing I 
> > > >> > > call
> > > >> > > recycle on everything. I null everything. I run GC manually.
>
> > > >> > > I then try edit another image and I get an out of VM memory error.
> > > >> > > Bitmap exceeds etc etc.
>
> > > >> > > I am looking at the heap and the secone edit doesnt seem to cause 
> > > >> > > it
> > > >> > > to increase at all.
>
> > > >> > > What else can I do. Surely google cannot possibly be suggesting 
> > > >> > > that
> > > >> > > we can open one large bitmap per session and thats it?- Hide 
> > > >> > > quoted text -
>
> > > >> - Show quoted text -
>
> > > --
> > > 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- Hide quoted 
> > > text -
>
> > - Show quoted text -

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to