public LowMemoryException createLowMemoryIfNeeded(Function function,
      Set<? extends DistributedMember> memberSet) {
    if (function.optimizeForWrite() && !(function instanceof AllowExecutionInLowMemory)
        && !MemoryThresholds.isLowMemoryExceptionDisabled()) {
      Set<DistributedMember> criticalMembersFrom = getHeapCriticalMembersFrom(memberSet);
      if (!criticalMembersFrom.isEmpty()) {
        return new LowMemoryException(
            String.format(
                "Function: %s cannot be executed because the members %s are running low on memory",
                function.getId(), criticalMembersFrom),
            criticalMembersFrom);
      }
    }
    return null;
  }
Deliver a memory event from one of the monitors to both local listeners and remote resource
managers. Also, if a critical event is received and a query monitor has been enabled, then the
query monitor will be notified.

Package private for testing.

@param event Event to process.
@param eventOrigin Indicates where the event originated e.g. notification vs polling
geode-core/src/main/java/org/apache/geode/internal/cache/control/HeapMemoryMonitor.java