memory size from MIDP phone!

dear all:how can i know the free memory size from MIDP phoe by java program!thanks!
[125 byte] By [wthomasu] at [2007-9-26 14:18:21]
# 1

[wthomasu],

You can use the Runtime.getRuntime().freeMemory() and Runtime.getRuntime().totalMemory() to get the amount of free memory available and total memory available.

Try to add this code sniplet to your MIDlet:

.

.

.

public void startApp() {

Runtime rt = Runtime.getRuntime();

rt.gc();

long freeMem = rt.freeMemory();

long totalMem = rt.totalMem();

System.out.println("Free Memory = " + freeMem);

System.out.println("Total Memory = " + totalMem);

.

.

.

.

This code sniplet will print out the free and total memory available for a java application during runtime.

HTH.

Allen Lai

Developer Technical Support

SUN Microsystems

http://www.sun.com/developers/support/

allenlai at 2007-7-2 15:53:42 > top of Java-index,Java Mobility Forums,Java ME Technologies...