54367

RAM increase - android service

Question:

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 !

Answer1:

there are <a href="http://developer.android.com/tools/debugging/ddms.html" rel="nofollow">eclipse android sdk tools to detect the current heap allocation size</a>, 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 <a href="http://www.youtube.com/watch?v=yhv8l9F44qo" rel="nofollow">Volley</a> 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).

Recommend

  • Pointer help in C/C++ [closed]
  • Listview setOnItemClickListener - Not working for custom listview but working into simple listview
  • Using grep to read a log for pattern1 in the file and print only lines containing pattern1. Stop sea
  • Android parse error Installation error: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED (because of Capital
  • Storing Data in a Variable vs Inline Arithmetic
  • Should concrete implementation provide any public API not present in the interface it implements?
  • Measure heap used by each object in Java [closed]
  • Can't get LogCat (Alcatel OneTouch Evolve)
  • App Memory Usage differs between Devices
  • Best Datagrid for Bootstrap/jQuery?
  • WebApp in AppServices vs CloudService
  • Can I use Jquery to automatically find and set the width and height of a variety of images?
  • Facebook Messenger Platform - Detect user typing
  • Counting Treaps
  • F#: In which memory area is the continuation stored: stack or heap?
  • Using MouseListener to select a range of cells in a grid
  • Getting NullPointer exception with File.listfiles()
  • Jquery popup on mouse over of calendar control
  • Android application: how to use the camera and grab the image bytes?
  • How to revert to previous XCode version?
  • How to add git credentials to the build so it would be able to be used within a shell code?
  • Android - Material Design - NavigationView - How to put vertical scroll?
  • How to get Eclipse Oxygen to run on Java 9
  • D3 nodes and links from JSON with nested arrays of children
  • Google Custom Search with transparent background
  • Change multiple background-images with jQuery
  • Why is an OPTIONS request sent to the server?
  • Insert into database using onclick function
  • Android screen density dpi vs ppi
  • What is Eclipse's Declaration View used for?
  • Get object from AWS S3 as a stream
  • DirectX11 ClearRenderTargetViewback with transparent buffer?
  • Can I make an Android app that runs a web view in Chrome 39?
  • Change an a tag attribute in JavaScript based on screen width
  • VB.net deserialize, JSON Conversion from type 'Dictionary(Of String,Object)' to type '
  • PHP: When would you need the self:: keyword?
  • Acquiring multiple attributes from .xml file in c#
  • MATLAB: Piecewise function in curve fitting toolbox using fittype
  • reshape alternating columns in less time and using less memory
  • How can I use threading to 'tick' a timer to be accessed by other threads?