I have an empty activity. this activity has a simple hello world. Created using New|Android application in eclipse. What I observe is that if I dump the dalvik private memory of this application, everytime the activity is reloaded (orientation change) I see a rise in dalvik private memory for this process. Below is the log. Is this the right observation ? Please let me know
06-06 15:38:38.139: D/hworld(5477): DalvikPM1956
06-06 15:38:41.599: D/hworld(5477): DalvikPM2120
06-06 15:38:43.989: D/hworld(5477): DalvikPM2240
06-06 15:38:45.959: D/hworld(5477): DalvikPM2364
06-06 15:38:47.769: D/hworld(5477): DalvikPM2488
06-06 15:38:49.999: D/hworld(5477): DalvikPM2612
06-06 15:38:51.989: D/hworld(5477): DalvikPM2736
06-06 15:38:54.019: D/hworld(5477): DalvikPM2852
06-06 15:38:55.789: D/hworld(5477): DalvikPM2976
06-06 15:38:57.779: D/hworld(5477): DalvikPM3088
06-06 15:39:04.389: D/hworld(5477): DalvikPM3236
06-06 15:39:09.389: D/hworld(5477): DalvikPM3364
06-06 15:39:10.389: D/hworld(5477): DalvikPM3484
06-06 15:39:11.789: D/hworld(5477): DalvikPM3604
Code
package com.ahw.android_hello_world;
import java.util.Iterator;
import java.util.List;
import android.os.Bundle;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.content.Context;
import android.util.Log;
import android.view.Menu;
public class MainActivity extends Activity {
protected Iterator i;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Context context = getApplicationContext();
ActivityManager manager = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
List<RunningAppProcessInfo> list= manager.getRunningAppProcesses();
for(i = list.iterator(); i.hasNext(); )
{
RunningAppProcessInfo p = (RunningAppProcessInfo)i.next();
if(p.processName.compareTo("com.ahw.android_hello_world")==0){
int[] pids = new int[1];
pids[0] = p.pid;
ActivityManager activityManager = (ActivityManager)
getSystemService(Context.ACTIVITY_SERVICE);
android.os.Debug.MemoryInfo[] MI = activityManager.getProcessMemoryInfo(pids);
Log.d("hworld","DalvikPM" + MI[0].dalvikPrivateDirty);
break;
}
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
Update:::: Got a bit curious and looked at Advanced Task Manager my apps memory usage and it is shocking 6.8MB and it reached to 8mb and more by just changing the orientation. What on earth is a hello world take 8mb for ? On a mobile device ?