Some of you probably know that some of core java APIs make explicit calls to System.gc(). I know two cases when this happens:
So, questions are:
RMI calls the System.gc() in case there are distributed objects which need to be cleaned up. You can make it perform GC less often or effectively turn it off.
You can avoid direct ByteBuffer needing a GC to clean them up on the Sun/Oracle JVM by calling
ByteBuffer bb = ByteBuffer.allocateDirect(SIZE);
((DirectBuffer) bb).cleaner().clean();
这篇关于核心 API 调用 System.gc()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!