I don't understand why it's not just possible to (easily) say, please, free all the memory in the native heap *now* - I don't care if I have to wait a bit, for garbage collection and so on. But this is not possible and I have just to rely on the system and see how my app keeps crashing...
On Sunday, July 15, 2012 12:35:44 AM UTC+2, user123 wrote: > > My app has a lot static images (backgrounds, buttons, etc.) and a lot of > small images, which loads from the web. These images are shown in a list > view, for example. > > I'm looking for a strategy to avoid out of memory errors. In the devices > with less than 25 mb it runs out of memory very soon and crashes. > > What I have done: > > - Put the static images with the correct resolution in the correct folder > (in this specific case it's hdpi). > - Create a singleton class which caches the dynamically loaded images. > > Even if I disable the caching in the singleton class, I'm running out of > memory. I logged the native usage with Debug.getNativeHeapAllocatedSize() > and I know that bitmaps are the cause of the problem. > > I can't lose quality of the images. > > I would take in account slower loading speed, as long as the app doesn't > crash! But calling System.gc() doesn't seem to be reliable, even less with > native heap, and recycle manually the bitmaps at the end of each activity > is a pain, because first, I have to initialize all the backgrounds in code, > in order to get a reference to the bitmap, then I have to use some data > structure, to hold all the bitmaps, and at the end of each activity call > recycle on all, and then I have also to manage, that, in the next activity, > I don't try to use the same bitmap instances, because I'll get exception > "trying to use a recycled bitmap". > > So what do I have to do? Please help... > -- 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

