日期:2014-05-20  浏览次数:20595 次

下面一段话是否有错,如果有,错在哪?请大家指导
Java技术允许使用fianlize()方法在垃圾搜集器将对象从内存中清除出去之前做必要的清理工作.这个方法会立即调用System.gc()或Runtime.getRuntime()对应的native方法进行垃圾回收.它是在Object类中定义的,因此所有的类都继承了它.

------解决方案--------------------
调用那个finalize方法并不能立刻去垃圾回收的,这个是受jvm控制的,不要以为他随时都可以做
------解决方案--------------------
或者可以理解为,gc动作只是一个标识,标识告诉jvm可以回收了,但是jvm可能不会立即执行回收操作。
------解决方案--------------------
AIP中的描述
public static void gc()
Runs the garbage collector. 
Calling the gc method suggests that the Java Virtual Machine expend effort toward recycling unused objects in order to make the memory they currently occupy available for quick reuse. When control returns from the method call, the Java Virtual Machine has made a best effort to reclaim space from all discarded objects. 

Calling the gc method suggests-----仅仅是建议虚拟机收回内存,什么时候收回是不能确定的。
------解决方案--------------------
yes 楼上说得很明白了。。。