3 ms·
Here's a simple practical guide to tune the Java GC properly: http://stackoverflow.com/a/37448602/5994461 http://stackoverflow.com/a/37448602/5994461 The only
by user5994461 10y ago
Here's a simple practical guide to tune the Java GC properly: http://stackoverflow.com/a/37448602/5994461 http://stackoverflow.com/a/37448602/5994461
The only thing you need to do nowadays is set "-Xmx__g -Xms__g" to configure the min and max heap size (replace __with a number).
There is only one rule to follow: The min and max heap must be the EXACT SAME number. (Basically, the heap must be fixed size).
If they're not, the GC will resize the heap during the program execution, which is a very expensive process that will freeze the application and ruin performances.
---
https://www.reddit.com/r/programming/comments/5fyhjb/golangs_realtime_gc_in_theory_and_practice_pusher/daof47v/ https://www.reddit.com/r/programming/comments/5fyhjb/golangs...
That comment is terrible advice. "-Xmx800m" then "-Xmx400m". He sets the max heap without setting the min, plus he runs the test for only a very short time not enough to stabilize the heap nor the optimizer. Bad bad bad.
- titzer 10y ago> There is only one rule to follow: The min and max heap must be the EXACT SAME number. (Basically, the heap must be fixed size). If they're not, the GC will resize the heap during the program execution, which is a very expensive process that will freeze the application and ruin performances. I doubt this is true of the JVM GC. Adaptive heap size tuning is also in V8 and it doesn't require an expensive operation like a full GC to accomplish (e.g. the whole heap is not copied during this operation). The GC can simply add more pages of memory after a minor GC and promote some of the objects from the young gen to the old gen. So it doesn't have to be more expensive than a young gen (minor) GC.
- user5994461 10y agoIt is true. One of the reddit comment states that they divided the latency by 5 after they reconfigured the min and max heap properly and let the program run for longer. The GC is in a constant battle to keep the program running within memory bounds. If you make it think that the program can run in 20MB by not giving a setting, it will try to fit the program in 20MB and clean the heap all the time (till it gives up and grow the heap). The GC needs to know it's bound to it doesn't bother running when not necessary AND it can decide how much space is available to keep short/long lived objects.