Search in sources :

Example 1 with NativeMemoryAllocationRefusedError

use of org.neo4j.internal.unsafe.NativeMemoryAllocationRefusedError in project neo4j by neo4j.

the class UnsafeDirectByteBufferAllocator method allocate.

@Override
public synchronized ScopedBuffer allocate(int bufferSize, MemoryTracker memoryTracker) {
    assertOpen();
    try {
        var byteBuffer = new NativeScopedBuffer(bufferSize, memoryTracker);
        allocations.add(byteBuffer);
        return byteBuffer;
    } catch (NativeMemoryAllocationRefusedError allocationRefusedError) {
        // What ever went wrong fallback to on-heap buffer.
        return new HeapScopedBuffer(bufferSize, memoryTracker);
    }
}
Also used : HeapScopedBuffer(org.neo4j.io.memory.HeapScopedBuffer) NativeScopedBuffer(org.neo4j.io.memory.NativeScopedBuffer) NativeMemoryAllocationRefusedError(org.neo4j.internal.unsafe.NativeMemoryAllocationRefusedError)

Aggregations

NativeMemoryAllocationRefusedError (org.neo4j.internal.unsafe.NativeMemoryAllocationRefusedError)1 HeapScopedBuffer (org.neo4j.io.memory.HeapScopedBuffer)1 NativeScopedBuffer (org.neo4j.io.memory.NativeScopedBuffer)1