RAM increase - android service

大兔子大兔子 提交于 2019-12-13 06:24:39

问题


I made some changes in my android service, like declared a hashmap of bitmaps as member variable, and populated it dynamically.

I am concerned that bitmaps might take up considerable RAM.

How can I confirm how much is the RAM usage increase after my changes. Is there any tool to check this ?

If anybody has worked in this area before, please help !


回答1:


there are eclipse android sdk tools to detect the current heap allocation size, but there is much simpler way to know current heap size:

just search in logcat for the words "Grow heap". every time the heap size of you application is grow - this log is printed to logcat, indicating also the current heap size.

it would look something like this:

02-22 11:20:57.040: I/dalvikvm-heap(5313): Grow heap (frag case) to 213.551MB for 3850256-byte allocation

generally, to avoid situation of too much bitmaps allocations, and to allocate bitmaps automatically on the scale type required for display, you should use library such Volley to handle for you the caching, and remote server fetching.

Volley mad by Google, and been use by the Google Play application for handling all requests in front of the server, and provides also smart ImageLoader that doing for you automatically the download,decode in correct sample size, displaying, memory cache and storage cache (if specified).



来源:https://stackoverflow.com/questions/21183549/ram-increase-android-service

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