Redian新闻
>
Java都在什么时候进行Garbage collection?
avatar
Java都在什么时候进行Garbage collection?# Java - 爪哇娇娃
t*o
1
只在new一个object或者array的时候才有可能产生Garbage collection吗?还有没
有可能在其他情况下触发
avatar
f*h
2
of course it could. GC is running at a separate thread.

【在 t****o 的大作中提到】
: 只在new一个object或者array的时候才有可能产生Garbage collection吗?还有没
: 有可能在其他情况下触发

avatar
t*o
3
譬如还有什么能够触发Garbage collection?
不是抬杠,实在是想知道。。。

【在 f********h 的大作中提到】
: of course it could. GC is running at a separate thread.
avatar
f*h
4
jvm will decide when to use GC,and you
can also call GC explicitly.
check javadoc of GC

【在 t****o 的大作中提到】
: 譬如还有什么能够触发Garbage collection?
: 不是抬杠,实在是想知道。。。

avatar
m*m
5
java执行GC是不确定的, 除非force GC.

【在 t****o 的大作中提到】
: 只在new一个object或者array的时候才有可能产生Garbage collection吗?还有没
: 有可能在其他情况下触发

avatar
c*z
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.
avatar
z*g
7
You can't force GC.

【在 m*m 的大作中提到】
: java执行GC是不确定的, 除非force GC.
avatar
o*v
8
System.gc();

【在 z****g 的大作中提到】
: You can't force GC.
avatar
z*g
9
This only suggest garbage collect to run, not really forcing it.
read your java book.

【在 o**v 的大作中提到】
: System.gc();
avatar
o*v
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.

avatar
z*e
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

avatar
g*g
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.

avatar
c*g
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吗?还有没
: 有可能在其他情况下触发

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。