2 ms·
GC usually only runs when the process wants to allocate an object but there's no space left on the heap. It's entirely possible that it did a bunch of work prev
by cherrycherry98 1y ago
GC usually only runs when the process wants to allocate an object but there's no space left on the heap. It's entirely possible that it did a bunch of work previously which created a bunch of garbage now waiting to be cleaned up. See the G1PeriodicGCInterval flag to enable idle collections (assuming G1).
Java is also fairly greedy with memory by default. It likes to grow the heap and then hold onto that memory unless 70% of the heap is free after a collection. The ratios used to grow and shrink the heap can be tuned with MinHeapFreeRatio and MaxHeapFreeRatio.
- _w1tm 1y agoWhy do Java developers still have to tune stuff like that?
- frollogaston 1y agoBefore I even went on my rant, I was guessing there's just some confusing default like this but there's also some historical reason why it's like that.
- deleted 1y ago[deleted]