to know memory status this code works
import javax.microedition.lcdui.*;
/**
* @author Mohammed Ersan
*/
public class Main extends MIDlet implements CommandListener {
Display display;
Form form1;
Command exitcmd, refreshcmd;
public Main() {
exitcmd = new Command("Exit", Command.BACK, 1);
refreshcmd = new Command("Refresh", Command.OK, 0);
display = Display.getDisplay(this);
form1 = new Form("Memory Status");
form1.addCommand(refreshcmd);
form1.addCommand(exitcmd);
form1.setCommandListener(this);
display.setCurrent(form1);
}
public void startApp() {
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable d) {
if (c == exitcmd) {
notifyDestroyed();
}
if (c == refreshcmd) {
form1.deleteAll();
printMemoryStatistics();
}
}
public void printMemoryStatistics() {
Runtime rt = Runtime.getRuntime();
form1.append("***MemoryStatistics***\n");
form1.append("FreeMemory=" + rt.freeMemory() + "\n");
form1.append("Used Memory=" + (rt.totalMemory() - rt.freeMemory()) + "\n");
form1.append("Total Memory=" + rt.totalMemory() + "\n");
form1.append("******************");
}
}
import javax.microedition.midlet.*;

