public void keep_testOutOfOffHeapMemoryErrorClosesCache() {
    // this test is redundant but may be useful
    final GemFireCacheImpl gfc = createCache();
    try {
      MemoryAllocator ma = gfc.getOffHeapStore();
      assertNotNull(ma);
      final long offHeapSize = ma.getFreeMemory();
      assertEquals(0, ma.getUsedMemory());
      StoredObject mc1 = ma.allocate(64);
      assertEquals(64 + perObjectOverhead(), ma.getUsedMemory());
      assertEquals(offHeapSize - (64 + perObjectOverhead()), ma.getFreeMemory());
      mc1.release();
      assertEquals(offHeapSize, ma.getFreeMemory());
      assertEquals(0, ma.getUsedMemory());
      // do an allocation larger than the slab size
      try {
        ma.allocate(1024 * 1024 * 10);
        fail("Expected an out of heap exception");
      } catch (OutOfOffHeapMemoryException expected) {
        // passed
      }
      assertEquals(0, ma.getUsedMemory());

      final WaitCriterion waitForDisconnect = new WaitCriterion() {
        @Override
        public boolean done() {
          return gfc.isClosed();
        }

        @Override
        public String description() {
          return "Waiting for disconnect to complete";
        }
      };
      GeodeAwaitility.await().untilAsserted(waitForDisconnect);

      assertTrue(gfc.isClosed());
    } finally {
      closeCache(gfc, false);
    }
  }
Basic test of regions that use off heap storage. Subclasses exist for the different types of
offheap store.
geode-core/src/integrationTest/java/org/apache/geode/internal/offheap/OffHeapRegionBase.java