One does need to keep in mind that naively loading, say, an 8 megapixel image will take about 16mb of storage. And on some platforms (not sure about Android) simply having 6mb of heap available does not mean that there's 6mb CONTIGUOUS, as would be needed for a large object.
On Apr 27, 1:24 pm, dnkoutso <[email protected]> wrote: > Hey everyone, > > I got an OOM. I know it has been covered alot by previous questions but mine > has to do with the internals of Android. > > As I am loading images at random points I get this dreaded OOM exception. > > I do have my images in an HashMap>. From the SoftReferences definition I > would expect the Drawables to be GC'ed if memory is not enough. > > In contrast, from my previous research I see that the bitmap in the drawable > is allocated in a different heap (the native heap) than my applications > heap. That explains why on DDMS despite the fact I see 6MB of memory I am > using, my app still crashes. > > It also seems that SoftReferences are "perfect" for caches and are > recommended by Android engineers to use. > > My question is, since my application heap never reaches the MAX point, this > should mean my SoftReferences are never GC'ed. > > How can I resolve this problem? Is there really any gains from using > SoftReferences then? Am I not understanding something correctly? > > Thanks! -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

