private void startMonitoring() {
    synchronized (this) {
      if (started) {
        return;
      }

      final boolean statListenerStarted = startCacheStatListener();

      if (!statListenerStarted) {
        startMemoryPoolPoller();
      }

      startJVMThresholdListener();

      started = true;
    }
  }
Monitoring is done using a combination of data from the JVM and statistics collected from the
cache. A usage threshold is set on the MemoryMXBean of the JVM to get notifications when the
JVM crosses the eviction or critical thresholds. A separate usage collection is done either by
setting up a listener on the cache stats or polling of the JVM, depending on whether stats have
been enabled. This separate collection is done to return the state of the heap memory back to a
normal state when memory has been freed.
geode-core/src/main/java/org/apache/geode/internal/cache/control/HeapMemoryMonitor.java