Android Out of Memory error with Lazy Load images

后端 未结 5 1226
挽巷
挽巷 2020-12-05 22:17

I found Fedor\'s code here and implemented it into my project. The only difference is that my application does not have a list view, rather, I am accessing 1 image at a time

5条回答
  •  春和景丽
    2020-12-05 22:51

    Generally, your in-memory image cache declaration should look something like:

    private static HashMap> cache = 
        new HashMap>();
    

    Note your OOM problems may not necessarily be related to your Bitmap cache. Always ensure you stop/interrupt the thread spawned by your image loader in your Activity's onDestroy method or in the finalize of any other class that is managing it.

    Use the Eclipse Memory Analyzer Tool in conjunction with DDMS to analyze your application's memory usage: http://www.eclipse.org/mat/

提交回复
热议问题