I**A 发帖数: 2345 | 1 下面的code,run 了gc之后区别还挺大的。。请教大家,gc都free了哪些memory?
thanks!
public class MemTest {
public static void main(String[] args){
Runtime rt = Runtime.getRuntime();
long wasFree, isFree;
isFree = rt.freeMemory();
do{
wasFree = isFree;
System.out.println("before " + isFree ); //here it is 4991136
rt.runFinalization();
rt.gc();
isFree = rt.freeMemory();
System.out.p | m******t 发帖数: 2416 | 2
Mostly allocated during the two System.out.println calls.
【在 I**A 的大作中提到】 : 下面的code,run 了gc之后区别还挺大的。。请教大家,gc都free了哪些memory? : thanks! : public class MemTest { : public static void main(String[] args){ : Runtime rt = Runtime.getRuntime(); : long wasFree, isFree; : isFree = rt.freeMemory(); : do{ : wasFree = isFree; : System.out.println("before " + isFree ); //here it is 4991136
|
|