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

      Thread t =
          new LoggingThread("OffHeapMemoryListener", offHeapMemoryUsageListener);
      t.setPriority(Thread.MAX_PRIORITY);
      t.start();
      memoryListenerThread = t;

      memoryAllocator.addMemoryUsageListener(this);

      started = true;
    }
  }
Start monitoring off-heap memory usage by adding this as a listener to the off-heap memory
allocator.
geode-core/src/main/java/org/apache/geode/internal/cache/control/OffHeapMemoryMonitor.java