Skip to content

Instantly share code, notes, and snippets.

@johnkil
Created May 29, 2012 09:36
Show Gist options
  • Save johnkil/2823551 to your computer and use it in GitHub Desktop.
Save johnkil/2823551 to your computer and use it in GitHub Desktop.
Check heap size on the android device
package com.miz.heapsize;
import android.app.Activity;
import android.app.ActivityManager;
import android.os.Bundle;
import android.widget.TextView;
public class CheckHeapActivity extends Activity {
private TextView text;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ActivityManager am = ((ActivityManager)getSystemService(Activity.ACTIVITY_SERVICE));
int memory = am.getMemoryClass();
int largeMemory = am.getLargeMemoryClass();
text = (TextView) findViewById(R.id.textView1);
text.setText("Normal heap size: " + memory
+ "\nLarge heap size: " + largeMemory);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment