@Test
  public void testPersistentChangeFromHeapToOffHeap() {
    GemFireCacheImpl gfc = createCache(true);
    Region r = null;
    final String value = "value big enough to force off-heap storage";
    try {
      r = gfc.createRegionFactory(RegionShortcut.LOCAL_PERSISTENT).setOffHeap(false)
          .create("changedFromHeapToOffHeap");
      r.put("key", value);
    } finally {
      closeCache(gfc, false);
    }
    gfc = createCache(true);
    try {
      r = gfc.createRegionFactory(RegionShortcut.LOCAL_PERSISTENT).setOffHeap(true)
          .create("changedFromHeapToOffHeap");
      assertEquals(true, r.containsKey("key"));
      LocalRegion lr = (LocalRegion) r;
      RegionEntry re = lr.getRegionEntry("key");
      if (!(re instanceof OffHeapRegionEntry)) {
        fail("expected re to be instanceof OffHeapRegionEntry but it was a " + re.getClass());
      }
      assertEquals(value, r.get("key"));
    } finally {
      if (r != null && !r.isDestroyed()) {
        r.destroyRegion();
      }
      closeCache(gfc, false);
    }
  }
This method retains both ohOldValue and ohNewValue
geode-core/src/integrationTest/java/org/apache/geode/internal/offheap/OffHeapRegionBase.java