Hi,
I think both "System.gc()" and "throw/catch OOM" are OK to trigger a GC.
I grepped jdk/test, and found that "System.gc()" was used 524 times and
OOME was catched 330 times.
It seems that "System.gc()" is more widely used by developers.
Although I prefer "System.gc()" in this case, it doesn't mean I don't
like "throw/catch OOM".
Probably I'd like to use "throw/catch OOM" to trigger a GC next time.
Thanks a lot.
Best regards,
Jie
On 2019/1/8 上午3:32, Sergey Bylokhov wrote:
Hello,
On 05/01/2019 16:05, Fu Jie wrote:
As far as I know, GC will finally be triggered if "System.gc()" is
called repeatedly with the JVM flag -XX:-DisableExplicitGC.
This option is specified with -XX, which are non-standard, not stable
and are subject to change without notice.
So it is not necessary to use it in the test, since the same result
can be achieved differently.
I do not see the problem in the "limit xmx" + "throw/catch OOM" +
"check the results".
I guess this is only correct way to check it without possibility to
introduce infinite loop which checks weakref.get().
Why don't you like it?