I have an application which has (mostly) images in its layouts. As I understand, Android is supposed to free the memory when the activity is not needed anymore. Thus, I am not releasing this Drawables used by my app's layouts when the Activity goes onPause() manually. I understand Android should do this.
Then, I use this code to check the memory status:
{
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
android.app.ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
activityManager.getMemoryInfo(memoryInfo);
Log.i("MEMCHECK", " memoryInfo.availMem " + memoryInfo.availMem + "\n" );
Log.i("MEMCHECK", " memoryInfo.lowMemory " + memoryInfo.lowMemory + "\n" );
Log.i("MEMCHECK", " memoryInfo.threshold " + memoryInfo.threshold + "\n" );
android.os.Debug.MemoryInfo[] memoryInfoArray = activityManager.getProcessMemoryInfo(pids);
for(android.os.Debug.MemoryInfo pidMemoryInfo: memoryInfoArray) {
Log.i("MEMCHECK", " pidMemoryInfo.getTotalPrivateDirty(): " + pidMemoryInfo.getTotalPrivateDirty() + "\n");
Log.i("MEMCHECK", " pidMemoryInfo.getTotalPss(): " + pidMemoryInfo.getTotalPss() + "\n");
Log.i("MEMCHECK", " pidMemoryInfo.getTotalSharedDirty(): " + pidMemoryInfo.getTotalSharedDirty() + "\n");
}
On every created activity, the memory footprint grows (the heap - getTotalPrivateDirty() ). I don't wanna do this since every 'kb' of memory in my app is really important.
Also, when this callback is processed:
Camera.PictureCallback mPictureCallback = new Camera.PictureCallback() {
public void onPictureTaken(byte[] imageData, Camera c) {
}
}
Empty, just like that. The heap grows from 10MB to 20MB. 100%. Is this normal? How to avoid?