Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public MemoryBlock allocate(long size) throws OutOfMemoryError {
final MemoryBlock memory = blockReference.get();
if (memory != null) {
assert (memory.size() == size);
if (MemoryAllocator.MEMORY_DEBUG_FILL_ENABLED) {
memory.fill(MemoryAllocator.MEMORY_DEBUG_FILL_CLEAN_VALUE);
}
return memory;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,21 @@ public void overlappingCopyMemory() {
public void memoryDebugFillEnabledInTest() {
Assert.assertTrue(MemoryAllocator.MEMORY_DEBUG_FILL_ENABLED);
MemoryBlock onheap = MemoryAllocator.HEAP.allocate(1);
MemoryBlock offheap = MemoryAllocator.UNSAFE.allocate(1);
Assert.assertEquals(
Platform.getByte(onheap.getBaseObject(), onheap.getBaseOffset()),
MemoryAllocator.MEMORY_DEBUG_FILL_CLEAN_VALUE);

MemoryBlock onheap1 = MemoryAllocator.HEAP.allocate(1024 * 1024);
MemoryAllocator.HEAP.free(onheap1);
Assert.assertEquals(
Platform.getByte(onheap1.getBaseObject(), onheap1.getBaseOffset()),
MemoryAllocator.MEMORY_DEBUG_FILL_FREED_VALUE);
MemoryBlock onheap2 = MemoryAllocator.HEAP.allocate(1024 * 1024);
Assert.assertEquals(
Platform.getByte(onheap2.getBaseObject(), onheap2.getBaseOffset()),
MemoryAllocator.MEMORY_DEBUG_FILL_CLEAN_VALUE);

MemoryBlock offheap = MemoryAllocator.UNSAFE.allocate(1);
Assert.assertEquals(
Platform.getByte(offheap.getBaseObject(), offheap.getBaseOffset()),
MemoryAllocator.MEMORY_DEBUG_FILL_CLEAN_VALUE);
Expand Down