I am working on app. When I check the used memory of app in device it shows the 50 MB (By Going in setting and app and running process . But at same time when I check the app allocated and free memory it is just MB.
How can I get the exact figure.
Related
I'm new to android. I have made an app that displays the data usage of all the apps in a recycler view (according to the date provided by the user).
When I see the RAM usage in Android Studio Profiler, it is showing a maximum of 120 MB.
But, when I open the RAM usage of my app in the physical device, it shows that the maximum RAM usage is around 500 MB, and average RAM usage is around 10 MB.
I used it for around 10 minutes. Is it normal or consuming a lot of RAM?
Android Studio may be showing wrong usage. How to get the correct usage in the profiler?
Can anyone please help me?
If the device has 4+GB of RAM it could be normal and depends of what kind of data you are showing for each row. If each row has a (quite large) Bitmap it could be normal.... However you can start Profiling your App using relative Tab in Android Studio. Then you can press appropriate button from the Profiler and show which Java Objects are using more memory and fix it if required.
Why does DDMS and Android's Running App (Settings->Apps->Running) show another allocated memory value?
DDMS shows that my application allocated memory size is equal ~40MB, on the other hand the Running App shows 80MB.
Which one value is correct? If DDMS value is correct how can I enforce the Running App to show correct value.
There is similar question, but answers are not enough for me.
I answer on my own question.
DDMS shows memory utilized only by Dalvik. The Running App show all memory which is utilized by application it is the sum of:
Native Heap
Dalvik Heap
Dalvik Other
Stack
Other dev
Graphics
and much more, in order to get detailed information about utilized memory please read Viewing Overall Memory Allocations.
I'm making a basic android application, but it is suffering from a LOT of garbage collection (the GC kicks in 4-5 times every second). I tried looking for the root cause and realized that my app has almost no memory as soon as the onCreate function is called.
As soon as the app starts, the DDMS shows almost 91% of the heap being used, mostly by 1-byte arrays. I also ran the memory analysis tool to see if I was leaking memory or something, and even after executing the app, it shows that most of the memory is used up by android.content.res.resources.
Why is my application losing so much memory to resources? The ONLY resource that my app has is a small JPEG image of 22KB. I read elsewhere that sometimes the free heap is misreported because of shared resources etc, but then the GC shouldn't kick in as often as it does when the app is running. Can someone help?
FWIW, the very same app run on a Galaxy S3 shows about 20% heap usage at the start, even though it shows the same amount of total memory (~10 MB). The problematic phone is a Galaxy S2.
Upgraded the phone to Cyanogenmod 10.1, and now the heap usage is ~30% at the start and the GC doesn't kick in anymore. Maybe a bug in the Samsung firmware?
I have run the MAT in eclipse for checking the memory leakage. I have attached the below report. I could see the size as 11.1 MB.
I need to know whether this is the healthy number for all the normal android phones ?
After I run the App in my phone, I checked the App cached memory in my phone settings->Apps->Running->show cached processes. It is shown as 20 MB. Why it is so? Is it fine to delete the cache programmatically when we come out of the APP?
I am getting a "bitmap size exceeds VM budget" error. I have read that there is a 16MB memory limit. In this thread Romain Guy says that "you can only allocate 16 MB
of memory for your entire application".
However, my app must be running out of memory long before it reaches that limit. So my question is: how do I allocate memory to my application ... how can I get the allocation to my app increased (within the 16MB maximum)?
As with any Java VM, the heap memory will automatically grow to the max size. But, bitmaps are allocated outside the VM, so you don't "see" them easily in the stats. The best thing you can do is make sure you don't use large bitmaps, or scale them down using
http://developer.android.com/reference/android/graphics/BitmapFactory.Options.html
From Eclipse you can generate a heap dump when you are on Android 1.6 or up and you can analyze the dump with Eclipse MAT.
Generally you can't control the max heap size on a real device, unless you are working with custom hardware or firmware.
There should be an article at developer.android.com on dumping the heap on 1.6, but I'm unable to find it. :(
Edit
Also, I have to mention that you can request more memory for applications by using
android:largeHeap="true"
in the manifest. But this is highly ill-adviced as most applications do not need this.
Note that the heap limit is device-dependent. On a Droid or Nexus One, that limit is 24 MB (to accommodate the larger graphic resources.)
If you're using threads, then the debugger might be the source of the problem. If you run the app under the debugger, then any threads created will still be retained by the debugger, even when they're finished running. This leads to memory errors that won't occur when the app is running without the debugger.
http://code.google.com/p/android/issues/detail?id=7979
https://android.googlesource.com/platform/dalvik/+/master/docs/debugger.html
I found the answer for your question recently.
Go to Android SDK Directory and
run sdk manager (Tools->android run this file)
In SDK manager go to Tools-->Manage AVDs
Now Android Virtual Device Manager Dialogue box is open..
in that window select your AVD and click Edit
Now in SD card section select SIZE and set 1024 MiB
in Hardware section click New and select property " Maximum VM application heap Size"
Now set 100 (based on your app requirement)
Finally click "Edit AVD"
After edit click refresh button on sdk Manager
Now run your app in AVD your problem is solved.