@Test
 public void testByteArrayAllocation() {
   GemFireCacheImpl gfc = createCache();
   try {
     MemoryAllocator ma = gfc.getOffHeapStore();
     assertNotNull(ma);
     final long offHeapSize = ma.getFreeMemory();
     assertEquals(0, ma.getUsedMemory());
     byte[] data = new byte[] {1, 2, 3, 4, 5, 6, 7, 8};
     MemoryChunk mc1 = (MemoryChunk) ma.allocateAndInitialize(data, false, false, null);
     assertEquals(data.length + perObjectOverhead(), ma.getUsedMemory());
     assertEquals(offHeapSize - (data.length + perObjectOverhead()), ma.getFreeMemory());
     byte[] data2 = new byte[data.length];
     mc1.readBytes(0, data2);
     assertTrue(Arrays.equals(data, data2));
     mc1.release();
     assertEquals(offHeapSize, ma.getFreeMemory());
     assertEquals(0, ma.getUsedMemory());
     // try some small byte[] that don't need to be stored off heap.
     data = new byte[] {1, 2, 3, 4, 5, 6, 7};
     StoredObject so1 = ma.allocateAndInitialize(data, false, false, null);
     assertEquals(0, ma.getUsedMemory());
     assertEquals(offHeapSize, ma.getFreeMemory());
     data2 = new byte[data.length];
     data2 = (byte[]) so1.getDeserializedForReading();
     assertTrue(Arrays.equals(data, data2));
   } finally {
     closeCache(gfc, false);
   }
 }