@Override public UnsafeMemoryChunk create(int size) { return new UnsafeMemoryChunk(size); } });
@Override protected MemoryChunk createChunk(int size) { return new UnsafeMemoryChunk(size); }
/** * Enables fill validation and creates the test victim. */ public void setUp() throws Exception { System.setProperty("gemfire.validateOffHeapWithFill", "true"); this.slab = new UnsafeMemoryChunk(SLAB_SIZE); this.allocator = SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{this.slab}); }
public void testCallbacksAreCalledAfterCreate() { SimpleMemoryAllocatorImpl.addLifecycleListener(this.listener); UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024); // 1k SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab}); Assert.assertEquals(1, this.afterCreateCallbacks.size()); Assert.assertEquals(0, this.afterReuseCallbacks.size()); Assert.assertEquals(0, this.beforeCloseCallbacks.size()); ma.close(); Assert.assertEquals(1, this.afterCreateCallbacks.size()); Assert.assertEquals(0, this.afterReuseCallbacks.size()); Assert.assertEquals(1, this.beforeCloseCallbacks.size()); }
public void testAddRemoveListener() { SimpleMemoryAllocatorImpl.addLifecycleListener(this.listener); SimpleMemoryAllocatorImpl.removeLifecycleListener(this.listener); UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024); // 1k SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab}); Assert.assertEquals(0, this.afterCreateCallbacks.size()); Assert.assertEquals(0, this.afterReuseCallbacks.size()); Assert.assertEquals(0, this.beforeCloseCallbacks.size()); ma.close(); Assert.assertEquals(0, this.afterCreateCallbacks.size()); Assert.assertEquals(0, this.afterReuseCallbacks.size()); Assert.assertEquals(0, this.beforeCloseCallbacks.size()); }
final int SMALL_ALLOC_SIZE = BIG_ALLOC_SIZE/2; final int TOTAL_MEM = BIG_ALLOC_SIZE; final UnsafeMemoryChunk slab = new UnsafeMemoryChunk(TOTAL_MEM); final AtomicReference<OutOfOffHeapMemoryException> ooom = new AtomicReference<OutOfOffHeapMemoryException>(); final OutOfOffHeapMemoryListener oooml = new OutOfOffHeapMemoryListener() {
try { if (uncreatedMemory >= maxSlabSize) { slabs[i] = new UnsafeMemoryChunk((int) maxSlabSize); uncreatedMemory -= maxSlabSize; } else { slabs[i] = new UnsafeMemoryChunk((int) uncreatedMemory);
public void testUsageEventListener() { final int perObjectOverhead = com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl.Chunk.OFF_HEAP_HEADER_SIZE; final int SMALL_ALLOC_SIZE = 1000; UnsafeMemoryChunk slab = new UnsafeMemoryChunk(3000); try { SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
final int SMALL_ALLOC_SIZE = BIG_ALLOC_SIZE/2; final int TOTAL_MEM = BIG_ALLOC_SIZE; UnsafeMemoryChunk slab = new UnsafeMemoryChunk(TOTAL_MEM); try { SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
int TOTAL_MEM = (maxTiny+perObjectOverhead)*BATCH_SIZE /*+ (maxBig+perObjectOverhead)*BATCH_SIZE*/ + round(TINY_MULTIPLE, minHuge+1+perObjectOverhead)*BATCH_SIZE + (TINY_MULTIPLE+perObjectOverhead)*BATCH_SIZE /*+ (MIN_BIG_SIZE+perObjectOverhead)*BATCH_SIZE*/ + round(TINY_MULTIPLE, minHuge+perObjectOverhead+1); UnsafeMemoryChunk slab = new UnsafeMemoryChunk(TOTAL_MEM); try { SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});