title: How to use MemoryPoolMXBean
body: <p>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... <strong>what pool to monitor?</strong> 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. <strong>Is this a good solution?</strong></p>
  
  <p>Thanks,
  Doron</p>