t****o 发帖数: 181 | 1 只在new一个object或者array的时候才有可能产生Garbage collection吗?还有没
有可能在其他情况下触发 |
f********h 发帖数: 149 | 2 of course it could. GC is running at a separate thread.
【在 t****o 的大作中提到】 : 只在new一个object或者array的时候才有可能产生Garbage collection吗?还有没 : 有可能在其他情况下触发
|
t****o 发帖数: 181 | 3 譬如还有什么能够触发Garbage collection?
不是抬杠,实在是想知道。。。
【在 f********h 的大作中提到】 : of course it could. GC is running at a separate thread.
|
f********h 发帖数: 149 | 4 jvm will decide when to use GC,and you
can also call GC explicitly.
check javadoc of GC
【在 t****o 的大作中提到】 : 譬如还有什么能够触发Garbage collection? : 不是抬杠,实在是想知道。。。
|
m*m 发帖数: 47 | 5 java执行GC是不确定的, 除非force GC.
【在 t****o 的大作中提到】 : 只在new一个object或者array的时候才有可能产生Garbage collection吗?还有没 : 有可能在其他情况下触发
|
c*z 发帖数: 62 | 6 Thers is no way to force GC to run, right?
I believe the GC is called when JVM is running out of memory.
【在 m*m 的大作中提到】 : java执行GC是不确定的, 除非force GC.
|
z****g 发帖数: 2497 | 7 You can't force GC.
【在 m*m 的大作中提到】 : java执行GC是不确定的, 除非force GC.
|
o**v 发帖数: 1662 | 8 System.gc();
【在 z****g 的大作中提到】 : You can't force GC.
|
z****g 发帖数: 2497 | 9 This only suggest garbage collect to run, not really forcing it.
read your java book.
【在 o**v 的大作中提到】 : System.gc();
|
o**v 发帖数: 1662 | 10 gc
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.
The call System.gc() is effectively equivalent to the call:
Runtime.getRuntime().gc()
See Also:
Runtime.gc()
【在 z****g 的大作中提到】 : This only suggest garbage collect to run, not really forcing it. : read your java book.
|
z***e 发帖数: 5393 | 11 no, even if you call GC explicitly, there is no guarantee JVM will do it
immediately.
a typical question for scjp test.
【在 f********h 的大作中提到】 : jvm will decide when to use GC,and you : can also call GC explicitly. : check javadoc of GC
|
g*****g 发帖数: 34805 | 12 What actually implemented in background is that once you call
GC, the priority of GC thread increases. There is no promise
highest priority thread will be executed immediately, as they
might be equal peers.
【在 z***e 的大作中提到】 : no, even if you call GC explicitly, there is no guarantee JVM will do it : immediately. : a typical question for scjp test.
|
c**g 发帖数: 274 | 13 about java GC, you can suggest, but can't demand. JVM has the final
say about when to do it.
【在 t****o 的大作中提到】 : 只在new一个object或者array的时候才有可能产生Garbage collection吗?还有没 : 有可能在其他情况下触发
|