public final class TrackingByteBufferAllocator extends Object implements ByteBufferAllocator, AutoCloseable
ByteBufferAllocator implementation that tracks whether all allocated buffers are released. It
throws the related exception at close() if any buffer remains un-released. It also clears the buffers at
release so if they continued being used it'll generate errors.
To be used for testing purposes.
| Modifier and Type | Class and Description |
|---|---|
static class |
TrackingByteBufferAllocator.ByteBufferAllocationStacktraceException |
static class |
TrackingByteBufferAllocator.LeakDetectorHeapByteBufferAllocatorException |
static class |
TrackingByteBufferAllocator.LeakedByteBufferException |
static class |
TrackingByteBufferAllocator.ReleasingUnallocatedByteBufferException |
| Modifier and Type | Method and Description |
|---|---|
ByteBuffer |
allocate(int size) |
void |
close() |
boolean |
isDirect()
Indicates if this allocator will produce ByteBuffers backed by direct memory.
|
void |
release(ByteBuffer b)
For RefCounted implementations using direct memory, the release method
needs to be called to free references to the allocated memory.
|
static TrackingByteBufferAllocator |
wrap(ByteBufferAllocator allocator) |
public static TrackingByteBufferAllocator wrap(ByteBufferAllocator allocator)
public ByteBuffer allocate(int size)
allocate in interface ByteBufferAllocatorpublic void release(ByteBuffer b) throws TrackingByteBufferAllocator.ReleasingUnallocatedByteBufferException
ByteBufferAllocatorrelease in interface ByteBufferAllocatorb - a ByteBufferTrackingByteBufferAllocator.ReleasingUnallocatedByteBufferExceptionpublic boolean isDirect()
ByteBufferAllocatorisDirect in interface ByteBufferAllocatorpublic void close()
throws TrackingByteBufferAllocator.LeakedByteBufferException
close in interface AutoCloseableTrackingByteBufferAllocator.LeakedByteBufferExceptionCopyright © 2023 The Apache Software Foundation. All rights reserved.