android memory usage and heap usage - android

when I look at my application in a memory utility (like Memory Usage app), it shows my application using 33MB of memory.
If while debugging my app, I go into DDMS and look at the heap, it's taking 4MB.
So at this point, I'm wondering where the other 29MB is being chewed up by. Secondly, my concern is that I could wind up spending a huge amount of time trying to trim that 4MB to something much smaller like say 2-3MB, but that hardly seems like I'm putting a dent in the memory usage. So how do i get that memory usage down much more significantly?

check and discoer it properly..........
http://elinux.org/Android_Memory_Usage
How do I discover memory usage of my application in Android?

Related

Benefits of reducing android app's memory consumption

I am trying to understand the benefits of memory consumption by an android application. One direct affect of consuming more memory is that the app crashes more often with OutOfMemoryError. But if my app rarely fails with OutOfMemoryError, is there a benefit in spending time on trying to reduce the memory consumption further ?
Avoiding leaks is not as easy as it seems. For example when user changes a configuration resulting the activity to get recreated, your memory consumption becomes almost 2 times due to the leaking activity if of course you have leaks.
The reason you should keep the ram usage as low as you can is about the free part of heap you can get which of course will reduce battery consumption and you can perform tasks on a larger scale. Lets assume you need to crop an image that user requested; this will usually get done by splitting the job into separate chunks and do it in a background thread while showing user a progress. In this example you can bite a larger size of the ram per each chunk and get the job done faster resulting in a happier end-user.
There are plenty other reasons as so to keep your ram usage at a lower level often ends up with more satisfied users.

how much memory usage is reasonable for a typical android application

I'm sorry for asking this duplicate question. But as you can see in that link the topic is saying one thing but the content is about something else.
I'm not asking how to manage or how to monitor the memory, just want to know how much memory usage you call a memory friendly app. And from what range you consider as using too much memory.
Thank you
Short Answer: As low as possible.
Long Answer: To allow multiple running processes, Android sets a hard limit on the heap size alloted for each app. The exact heap size limit varies between devices based on how much RAM the device has available overall. If your app has reached the heap capacity and tries to allocate more memory, the system throws an OutOfMemoryError, and to avoid running out of memory, you can to query the system to determine how much heap space you have available on the current device.
You can query the system for this figure by calling getMemoryInfo(), which provides information about the device's current memory status, including available memory, total memory, and the memory threshold—the memory level at which the system begins to kill processes.
For more details, see this
https://developer.android.com/topic/performance/memory

Android: why is memory usage for one application drasmatically larger than allowable memory for one process

As I researched, Android allocates limit memory for each process, maybe range from 16MB to 24MB for each one. Here is reference
Nevertheless when I view memory usage for one application in setting, I often see one normal application costs hundred megabytes for memory (on one process). There is a conflict here that I cannot understand.
Thanks :)
NDK code can use more system RAM than can a single Dalvik/ART process. Also, the app might be using more than one process, or it might be using android:largeHeap to request an above-normal heap size.

Lots of RAM use by very large byte arrays?

I have been trying to fix a memory leak in my app for a long time, and I keep running into dead ends. The app is heavily image-centric, so I use the Picasso library to handle caching and memory use. I passed the high ram use (up to 100-170mb for my app) to bad memory management on Picasso's part, but I did some testing and disabled memory caching for Picasso, which loads all my images, and there was not a very noticable drop in RAM usage. It was still using 90 to upwards of 170 mb of RAM. I did a full heap dump into a hprof file and opened it with MemoryAnalyzer to see this:
http://i.gyazo.com/6b8d884852fa7cae546fc4cad1fc44c9.png.
If I go to Path to GC Roots, it shows no roots and no parents. There is no link to any of these over 50,000,000 bytes in these 25 massive byte arrays, and I really don't know where to start looking for the cause of it.
Do you have any suggestions on what the bug could be and any possible fixes?
Thank you very much for helping me out!
Try to use LeakCanary to find the memory leak.
Also, you can try Fresco for image loading & displaying, it stores images in the native memory region, so you won't use too much memory from the managed region, GC won't take too much time and you could avoid OutOfMemoryErrors.

How much memory your app will take up when develop the android app?

Sometimes we encounter the memory issues,such as the OOM problems.And We inevitably have to manage the memory.Android has set a limit to the memory used bye each app.The maximum limit probably is the 32Min the early versions of android,such as 1.5,1.6,2.1.
Android of v4.0 has exceeded this limit.We can set android:largeHeap to "true" in the AndroidManifest,so the app could increase the memory limit.
I'm develeping the wallpaper app.The app can show many pictures in high definition.But the memory used by the app always reach the limit of more than 60M in the android of 720p, about 100M in the android of 1080p.
The overuse of memory is unacceptable for me.And I'm looking for the means to resolve it all the time.
My friends,How much memory your app will take up when you develop your app during debugging or running?Is there a memory-manage mechanism in the code?Look forward to your reply.
The amount of memory used by bitmaps is based on what's in the bitmap, not the size of the file. There's a few things you can do to reduce the footprint of the bitmap being loaded in to memory, which, in turn will reduce the amount of memory your app is using.
There's a great talk here from Google I/O for memory management that will help and another that will help you check to see if you have any memory leaks as well.
Also, note that if you use Bitmap.Config.RGB_565 you can half the amount of memory that the Bitmap is using (each pixel value is stored in 2 bytes instead of 4)

Categories

Resources