Memory issue with my Android app

两盒软妹~` 提交于 2019-12-08 06:44:29

This thing can be an easy fix for this

just add this line in your application tag in manifest file

android:largeHeap="true"

like this

<application android:largeHeap="true" android:allowBackup="true" ......

and if you want to more optimize your code then use Memory Analyser in eclipse

Looks like your app was built using layouts defined in xml files. These layouts uses images like images for background or source images for ImageButton or ImageView etc. All your drawables are usually stored in drawable-DENSITY folders. So you need to lower resolution of all of your drawables to save some RAM. Like if you have some drawable for ImageView lets call it new_image.jpg and its in drawable-hdpi and its resolution is 800x600 px try to resize it to 400x300 px (you could use a Farstone Image Viewer for this). Do that with every drawable in project and see what happens.
Also it could be that you are displaying images in ListViews using some ImageLoader like Glide (recommended) or UIL or Picasso or whatever use use. Such loaders are usually consuming a lot of RAM (which is configurable however) for caching needs and due to that at one point AOS fails to load, build and represent some your layout which uses images by itself.
Also I recommend you to lern how to display Bitmaps efficiently you MUST know such things.

Apart from bitmaps and drawables the most common problem is leaking memory through the Activity context. Make sure that you are not passing around the activity to callback listeners. A good tool to analyze memory is MAT(Memory Analyzer Tool). It helps you find out memory leaks in your app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!