private void doFreeOffHeapMemory(final int numAllocations, final int numDestroys) {
    assertThat(numDestroys <= numAllocations).isTrue();

    Region region = getCache().getRegion(OFF_HEAP_REGION_NAME);
    assertThat(region).isNotNull();
    assertThat(numDestroys <= region.size()).isTrue();

    String key = "KEY0";
    Object value = key;
    int destroyed = 0;

    while (destroyed < numDestroys) {
      key = "KEY" + ((int) (Math.random() * numAllocations));
      value = region.get(key);

      if (null != value) {
        region.destroy(key);
        ++destroyed;
      }
    }
  }
Performs some destroys to free off-heap allocations.

@param numAllocations the number of previous off-heap allocations
@param numDestroys the number of destroys to perform
geode-core/src/distributedTest/java/org/apache/geode/management/OffHeapManagementDUnitTest.java