学习JVM原理-Direct Memory只会在Full GC时回收

摘自《深入理解Java虚拟机》周志明著

Direct Memory满了之后,系统不会自动回收这段内存; 而是要等Tenured Generation满触发GC时,Direct Memory才会被跟着回收。

所以这一块很容易发生内存溢出. 为了防止这种事发生,你要么不把Heap设的过多,该Full GC的时候就Full GC; 要么在JVM参数里不禁止System.gc(),因为NIO的实现里会自己调用System.gc()

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.