android memory management outside heap
I am working on an application for android and we since we have lots of graphics, we use a lot of memory.
I monitor the memory heap size and its about 3-4 Mb , and peeks of 5Mb when I do something that requires more memory (and then goes back to 3). This is not a big deal, but some other stuff is handled outside the heap memory, like loading of drawables.
For example if I run the ddms tool outside eclipse, and go to sysinfo, I see that my app is taking 20Mb on the Droid and 12 on the G1, but heap size are the same in both, because data is the same but images are different.
So the questions are: How do I know what is taking the memory outside the heap memory? What other stuff takes memory outside the heap memory? Complex layouts (big tree) ? Animations?
Thanks
Daniel
Asked by: Miller240 | Posted: 25-01-2022
Answer 1
Bitmap objects takes a quite alot of memory.
Ex. if your app downloads a 10KB jpg from net and use BitmapFactory to decode it into a Bitmap that bitmap objects needs about 30-100KB memory, depending on the resolution of your image. 3bytes for each pixel (1 byte for each color)
And yes, all kind of object uses memory, like LinearLayouts, ImageViews etc... If you are creating and destroying many of these objects, ex. as you scroll / page through your images, there will be memory leaks. The gc() does not handle so-called short lived objects as fast as we would like.
*Keep the number of view objects at a stable level**, and recycle them instead of destroying and creating new ones.
REf: http://developer.android.com/resources/articles/track-mem.html
If your app reaches 20MB in memory, it may FC as the BitmapFactory is trying to decode the next image.
Answered by: Maria901 | Posted: 26-02-2022Answer 2
One obvious candidate is off course off-screen bitmaps (double-buffering by android?), since the screensize has ~4x as many pixels on the droid.
Answered by: Gianna633 | Posted: 26-02-2022Similar questions
power management - How to obtain Battery Stats in Android at runtime?
I want to display Battery level stats in my app. How can we obtain such information like Battery Power, Battery Voltage, etc.?
Android: stack management for views in a tab?
I see some answers here prefer views over activities as contents of tabs. Correct me if I am wrong. My understanding is that by switching out views, it's possible to keep the navigation flow inside a tab (more user friendly, I think). But I wonder how to manage the view stack then in case of the back button events. Also this could cause one giant Activity with large amount of views, which might not be good.
So I w...
Android ==> Mmory Management Questions?
My question are commented in the code
ImageView img = new ImageView();
this.layout.addView(img);
MyObject o = new Object(img);
// Do i need to set img to null?
ArrayList <MyObject> myArray = new ArrayList <MyObject>();
MyObject obj = new MyObject();
myArray.add(obj);
// Do i need to set obj to null?
key management - Android Secure Storage
I want to store some small but critical piece of information such as AES keys in my Android application. What would be the recommended way to do this? I do not want to hardcode keys as part of my application.
I look at KeyStore but it does not really solve my problem. It can store my keys given that I can provide a pas...
Map Marker Management, Android
I have a map that dispays markers. If the user clicks on a marker a popup shows up. A method calculates wheather there is a marker at the clicked position.
My Problem is that I have a lot of different markers, but in this method I can handle only one specific marker.
I need something like a general bitmap, that holds all marker resources. E.g. I do not wand to handle 100 markers manually, because all are a ...
java - Android dialog management
I'm developing an android app (if you want more info http://www.txty.mobi) and I am having some problems with dialogs management. I'm quite new to Android so the way I'm doing things completely wrong. If the case please just say so pointing me to the right documentation to follow.
Background:
The main blocks of the app so far ar...
Problem with Memory Management in Android image processing with http protocol
I have a problem with a memory management. I'm downloading some data through mine HTTP client. Next thing I want to display data to the user.
The problem is not stable, on some files of the same type it occurs, on some not. Stable thing is, that it is occurring on the same file.
Here is LogCat input.
Technically I have no clue what to do next. I tried, starting gc in the specific threads with no effect.
android activity sequence management issue
I have some problem with "how android manage its activity called from another activity"
I'm using the following code... whenever I execute the program on the device... it execute the "second "activity first before executing the "first" activity.
program display the "second" acitivy first. after pressing back button it display the "first" activity.
But I need to execute them in calling sequence as w...
power management - How to keep android device from sleeping while plugged in
I'd like to keep the screen on whenever one of my Activities are running and the phone is plugged in to a power source. I know that Wakelocks are tricky, so I'm looking for an example or some documentation on how to accomplish this specific goal.
memory management - Android: use up tons of RAM?
I'm looking to somehow enable access for my app to use up practically all the device's RAM. This app I am creating is not designed for general release, it is just a personal project, but it requires a ton (~128mb) of RAM. My Nexus One has 512MB of RAM, but yet I cannot allocate more then ~10MB of RAM max. How can I let my app allocate as much as it wants?
Still can't find your answer? Check out these communities...
Android Google Support | Android Community | Android Community (Facebook) | Dev.io Android