<span id="Label3"></p><p><p><br></p></p><p><p><br></p></p><p><p><br></p></p><p><p><br></p></p><p><p><br></p></p><p><p>First deal with this problem, with 1 weeks, very hard, desperately looking for the problem of the Oom memory overflow, but did not find the results, always thought it was their own use of the Picaso loading picture frame, only loaded the picture, but the activity destroyed, did not do memory release function, So try to solve the problem by yourself:</p></p><p><p><br></p></p><p><p>1. Change a picture frame: xutil picture frame</p></p><p><p>The result is just a bottle. There will still be oom, memory overflow issues</p></p><p><p><br></p></p><p><p>2. Image processing: Online said for large map, to do scaling processing, and the generated bitmap object memory processing</p></p><p><p></p></p><pre name="code" class="java"> private void initdisplayimageoption () {options = new Displayimageoptions.builder (). showimageonload ing (r.drawable.video_default)//set pictures to be displayed during the Download. Showimageforemptyuri (r.drawable.image_background_empty)//set Set picture URI is empty or wrong when the Picture//.showimageonfail (r.drawable.image_background_erro)//sets the picture to be displayed during error when loading/decoding the picture . cacheinmemory (false)///sets Whether the downloaded picture is in Memory. Cacheondisk (true)//sets whether the downloaded picture is slow to exist on the SD Card. Conside Rexifparams (true)//whether to consider the JPEG image exif parameter (rotate, flip). Imagescaletype (imagescaletype.exactly_stretched)//set the image to how to encode the party Display. bitmapconfig (Bitmap.Config.RGB_565)//set The decoding type of the Picture////.decodingoptions (android.graphics.Bi Tmapfactory.options Decodingoptions)//set The decoding configuration of the Picture. delaybeforeloading (0)//int Delayinmillis Set the delay time before download for you . resetviewbeforeloading (true)//set whether the picture is reset before downloading, reset. displayer (new fadeinbitmapdisplayer (100))//whether the diagram The animation time when the slices are loaded and fade in . Build ();//build complete} @Override protected void OnDestroy () {mam.poponeactivity (hostessdetailui.this); LOG.E ("ondestroy () isrun!!!"); Mhostessimgs.setadapter (null); /** release picture, control picture reference resource */bitmapdrawable bitmapdrawable = (bitmapdrawable) mhostessmiddle.getbackground (); Mhostessmiddle.setbackgroundresource (0); Bitmapdrawable.setcallback (null); Drawable.setcallback (null); Bitmap Bitmap = Bitmapdrawable.getbitmap (); If (bitmap! = null &&!bitmap.isrecycled ()) {bitmap.recycle ();//the Memory of the recovered picture is bitmap = null; } btp.recycle (); Recall the memory System.GC () of the image; Super.ondestroy (); }</pre><br>The result is the problem of oom, and the log does not see the GC operation, memory from 16MB to 96MB direct Flash back,<p><p></p></p><p><p><br></p></p><p><p>3. Change a powerful picture frame: Universal-image_loader (UIL)</p></p><p><p>See online said UIL is the most popular, the most users, the most personal configuration of the picture frame, so that their own replacement picaso, came to Uil's arms, but still reported oom problem, every time to see the log is running to 96MB Flash BACK.</p></p><p><p>Oneself doubt is oneself to UIL understanding not deep, configuration incomplete, still did not release memory. (have time to see the UIL source code Implementation)</p></p><p><p><br></p></p><p><p>4. Change to the latest picture processing Framework: Facebook's recommended fresco framework</p></p><p><p></p></p><pre name="code" class="java"><pre name="code" class="java">Dependencies { compile ' com.facebook.fresco:fresco:0.5.0+ ' }</pre></pre><br>Because this aspect of the explanation very few, oneself looked for a while, feel good complex, so went to see the official website document in as the use of introduction, a few simple operations, added to their own projects, not like others said to configure the ndk, compile What. and ran up and running, sure enough!! Memory heap does not reach 96MB oom problem as before, really is the latest thing will be the better<p><p></p></p><p><p><br></p></p><p><p>5. Remove the large image from the background to show the full</p></p><p><p>The program does not crash, the heart has a lot of comfort, after all, the problem has appeared for 1 weeks, However there are some individual pictures for a long time are not loaded out, fresco frame so good, why still have the picture can not be loaded out of you. And then look at the log prompt: loading the picture is too large to download, and then looked at the background to pull the picture size. Nani. , a picture 7mb!! The perfect frame for this kind of picture is also no way, so let the background processing of picture Specifications.</p></p><p><p><br></p></p><p><p>The final solution: replace the fresco frame + background image reduction Processing. There is no oom problem with the program NOW. So happy! (but the memory release problem, oneself still did not do well, need to improve!) )</p></p><p><p>Android Picture loading, OOM problem</p></p></span>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.