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 !

有帮助吗?

解决方案

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).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top