private void createPR(final String rName, final boolean accessor) {
    getSystem(getOffHeapProperties());
    InternalResourceManager irm = (InternalResourceManager) getCache().getResourceManager();
    irm.setCriticalOffHeapPercentage(90f);
    AttributesFactory<Integer, String> af = new AttributesFactory<>();
    if (!accessor) {
      af.setCacheLoader(new CacheLoader<Integer, String>() {
        final AtomicInteger numLoaderInvocations = new AtomicInteger(0);

        @Override
        public String load(LoaderHelper<Integer, String> helper) throws CacheLoaderException {
          Integer expectedInvocations = (Integer) helper.getArgument();
          final int actualInvocations = numLoaderInvocations.getAndIncrement();
          if (expectedInvocations != actualInvocations) {
            throw new CacheLoaderException("Expected " + expectedInvocations
                + " invocations, actual is " + actualInvocations + " for key " + helper.getKey());
          }
          return helper.getKey().toString();
        }

        @Override
        public void close() {}
      });

      af.setPartitionAttributes(new PartitionAttributesFactory().create());
    } else {
      af.setPartitionAttributes(new PartitionAttributesFactory().setLocalMaxMemory(0).create());
    }
    af.setOffHeap(true);
    getCache().createRegion(rName, af.create());
  }
Test that a Partitioned Region loader invocation is rejected if the VM with the bucket is in a
critical state.
geode-core/src/distributedTest/java/org/apache/geode/cache/management/MemoryThresholdsOffHeapDUnitTest.java