private boolean startCacheStatListener() {
    final GemFireStatSampler sampler = cache.getInternalDistributedSystem().getStatSampler();
    if (sampler == null) {
      return false;
    }

    try {
      sampler.waitForInitialization();
      Statistics si = getTenuredPoolStatistics(
          cache.getInternalDistributedSystem().getStatisticsManager());
      if (si != null) {
        sampler.addLocalStatListener(statListener, si, "currentUsedMemory");
        if (logger.isDebugEnabled()) {
          logger.debug("Registered stat listener for " + si.getTextId());
        }

        return true;
      }
    } catch (InterruptedException iex) {
      Thread.currentThread().interrupt();
      cache.getCancelCriterion().checkCancelInProgress(iex);
    }

    return false;
  }
Start a listener on the cache stats to monitor memory usage.

@return True of the listener was correctly started, false otherwise.
geode-core/src/main/java/org/apache/geode/internal/cache/control/HeapMemoryMonitor.java