JAVA作业,GC的效果
来源:互联网 发布:热血江湖传进阶数据 编辑:程序博客网 时间:2024/05/18 03:06
package demo;
public class DemoFinal {
private static Runtime runtime = Runtime.getRuntime();
private static boolean finalized;
private int buffer[] = new int[10000];
protected static long printFreeMemory(String prefix) {
long freeMemory = runtime.freeMemory();
System.out.print(prefix);
System.out.println("The free memory is " + freeMemory);
return freeMemory;
}
public static void main(String args[]) {
DemoFinal demoFinal = new DemoFinal();
printFreeMemory("");
demoFinal = null;
long time = System.currentTimeMillis();
runtime.gc();
while (finalized) ; //waiting for the finalize executed
System.out.print("The gc Action costs ");
System.out.print(System.currentTimeMillis()-time);
System.out.print(" Milliseconds");
}
protected void finalize() throws Throwable {
printFreeMemory("After GC,");
finalized = true;
}
}
public class DemoFinal {
private static Runtime runtime = Runtime.getRuntime();
private static boolean finalized;
private int buffer[] = new int[10000];
protected static long printFreeMemory(String prefix) {
long freeMemory = runtime.freeMemory();
System.out.print(prefix);
System.out.println("The free memory is " + freeMemory);
return freeMemory;
}
public static void main(String args[]) {
DemoFinal demoFinal = new DemoFinal();
printFreeMemory("");
demoFinal = null;
long time = System.currentTimeMillis();
runtime.gc();
while (finalized) ; //waiting for the finalize executed
System.out.print("The gc Action costs ");
System.out.print(System.currentTimeMillis()-time);
System.out.print(" Milliseconds");
}
protected void finalize() throws Throwable {
printFreeMemory("After GC,");
finalized = true;
}
}
- JAVA作业,GC的效果
- gc的效果
- Java GC的基本原理
- Java的GC机制
- Java的GC机制
- Java的GC机制
- Java的GC机制
- Java的GC机制
- java的GC
- Java GC的基础
- Java的GC机制
- Java的GC机制
- Java的GC机制
- java GC的误区
- Java的GC机制
- Java的GC机制
- Java的GC机制
- JAVA的GC线程
- 台风又来袭
- 制作最完美的GHOST纯净稳定版详细档案
- 宽屏游戏风波~~~
- 怎樣獲取客戶端ip及mac地址?
- 类中的回调函数(收藏)
- JAVA作业,GC的效果
- C# 异常处理
- eclipse进行J2ME程序打包出错解决方案
- 从给定网站抓取省市级城市数据
- 莱布尼兹的宏伟计划
- VC6中编译参数设置 (收藏)
- 社会生活中的十二条著名法则
- 生产者-消费者问题
- NHibernate中使用Equals方法的一个疑问