This site requires JavaScript, please enable it in your browser!
Greenfoot back
lux
lux wrote ...

2012/6/6

Question regarding Heap Space

lux lux

2012/6/6

#
Hello, according to that the normal Heap Space for Greenfoot applications is 64mb right? So i checked that with the following code:
public class bla extends World{

private static final Runtime runtime = Runtime.getRuntime ();

public bla(){

        super(600, 400, 1);
        System.out.printf( ""+ runtime.maxMemory());

}

}
but I am getting a max memoy near 256mb. So have there been any changes or is my way of measurement wrong? thanks for replies Edit: I checked again with the following code:
private static final Runtime runtime = Runtime.getRuntime ();

public bla(){

        super(600, 400, 1);
        runtime.gc();
        System.out.printf( ""+ runtime.freeMemory());

}

}
and altough I activated the carbage collector I only have an actual Heap Space size of 14mb... this is very confusing...
davmac davmac

2012/6/6

#
The post you refer to is a little bit out-of-date. The maximum heap size is chosen by Java, and is dependent on the amount of RAM in your system. 256mb should be about right for modern systems. You probably can't trust the return from 'freeMemory' too much. Greenfoot caches a lot of things, and will automatically release some memory if it gets low.
lux lux

2012/6/6

#
All right thank you.
You need to login to post a reply.