Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First,GC will not recycle the memory at once you called. Here are some advice from android developer website:</p> <ol> <li><p>Do not keep long-lived references to a context-activity (a reference to an activity should have the same life cycle as the activity itself)</p></li> <li><p>Try using the context-application instead of a context-activity</p></li> <li><p>Avoid non-static inner classes in an activity if you don't control their life cycle, use a static inner class and make a weak reference to the activity inside. The solution to this issue is to use a static inner class with a WeakReference to the outer class, as done in ViewRoot and its W inner class for instance</p></li> <li><p>A garbage collector is not an insurance against memory leaks</p></li> </ol> <p>Second, try to use BitmapFactory.options when you do not very care the quality of the bitmap.</p> <p>Third, use try catch to process the OutOfMemory exception in catch block.</p> <p>Finally, Use <a href="http://www.google.com/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;sqi=2&amp;ved=0CB4QFjAA&amp;url=http://eclipse.org/mat/&amp;ei=yGzdTuuKL4bwrQe6oe2oBA&amp;usg=AFQjCNGsu8KMqb5mhWwGpV02A1R6V_gzmA&amp;sig2=cpTLTHe3yaLU0rlQKzoqkQ">Memory Analyzer</a> . Open DDMS in Eclipse, in the toolbar there is a update heap button. you can use this to generate a hprof file, then use hprof-conv tool in your andorid-sdk-tools directory to convert the file to the specified format file that Memory Analyzer can read. Now you can use the Memory Analyzer to analysis the possible memory leak. It's really a good tool that will give you many suggestions to avoid outofmemory.</p> <p>Hope this will help you, If you find some better methods please tell me, i also face the outofmemory in my app.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload