@Override
  public void outOfOffHeapMemory(final OutOfOffHeapMemoryException cause) {
    synchronized (lock) {
      if (ids == null) {
        return;
      }
      if (Boolean.getBoolean(OffHeapStorage.STAY_CONNECTED_ON_OUTOFOFFHEAPMEMORY_PROPERTY)) {
        return;
      }

      final InternalDistributedSystem dsToDisconnect = ids;
      ids = null; // set null to prevent memory leak after closure!

      if (dsToDisconnect.getDistributionManager().getRootCause() == null) {
        dsToDisconnect.getDistributionManager().setRootCause(cause);
      }

      Runnable runnable = () -> {
        dsToDisconnect.getLogWriter()
            .info("OffHeapStorage about to invoke disconnect on " + dsToDisconnect);
        dsToDisconnect.disconnect(cause.getMessage(), false);
      };

      // invoking disconnect is async because caller may be a DM pool thread which will block until
      // DM shutdown times out

      String name = getClass().getSimpleName() + "@" + hashCode()
          + " Handle OutOfOffHeapMemoryException Thread";
      Thread thread = new LoggingThread(name, runnable);
      thread.start();
    }
  }
Used to asynchronously disconnect an InternalDistributedSystem when we run out of off-heap
memory. If the STAY_CONNECTED_ON_OUTOFOFFHEAPMEMORY_PROPERTY sys prop is set to true then this
listener will not disconnect.
geode-core/src/main/java/org/apache/geode/internal/offheap/DisconnectingOutOfOffHeapMemoryListener.java