4 ms·
The JVM (at least the Oracle/Sun version) has some scary seeming memory allocation policies. One of the biggest offenders is its complete unwillingness to ever
by theatrus2 15y ago
The JVM (at least the Oracle/Sun version) has some scary seeming memory allocation policies. One of the biggest offenders is its complete unwillingness to ever shrink the system allocated memory, even if the heap is 95% empty. For instance, if your application has a huge peak allocation period (whether your fault or an issue with soft references sticking about when you really don't want them), it will put memory pressure on the OS for the rest of its (process) life. If the JVM has an option of garbage collecting large amounts of objects or growing the heap, it generally prefers growing the heap. You can run quite a few Java applications with amazingly small heaps at everything will be fine (except for performance due to GC overhead).
The abstraction breaker here is that your application often has a set of ideal GC settings, which need to be set. You cannot forget about the garbage collector when using the JVM.