We are developing a server, and we want to program congestion control. We want to determine when the free heap is below a certain threshold, and stop accepting new data until the free memory returns again. Our first approach used runtime.freeMemory. This caused false positives, as the free heap fell below the threshold before the HA exploded. I found a similar question on this site, and the answer was to use MemoryPoolMXBean. This seems like the right way, as we can be notified when the free memory AFTER the GC is below the mark. But ... what is the monitoring pool? I do not want my implementation to depend on the type of GC that the JVM decided to use. One option is to summarize the use of all heap memory pools and use this as an indicator. This is a good decision?
Thanks Doron
source share