views:

67

answers:

1

Hi all. We develop a server and we want to program congestion control into it. What we want to do is detect when free heap is below a certain threshold and stop accepting new data until free memory goes up again. Our first approach used runtime.freeMemory. This caused false positives as free heap went below the threshold before GC kicked in. I found a similar question on this site and the answer was to use MemoryPoolMXBean. This looks like the right way since we can get a notification when free memory AFTER GC is below a thershold. But... what pool to monitor? I don't want my implementation to be dependent on the type of GC the JVM decided to use. One option would be to sum the usage of all heap memory pools and use that as a metric. Is this a good solution?

Thanks, Doron

A: 

Hey Doron, see this: link

it should help you with deciding which pool to use.

Happy Coding!

Boltimuss
Thanks for the reply but I'm not sure I can count on it. It just doesn't feel right to monitor memory pools based on their name. Our current solution is to monitor every pool that is of type heap.
Doron Tohar