Search in sources :

Example 6 with PhysicalFlushableChannel

use of org.neo4j.io.fs.PhysicalFlushableChannel in project neo4j by neo4j.

the class PhysicalFlushableChannelTest method releaseBufferMemoryOnClose.

@Test
void releaseBufferMemoryOnClose() throws IOException {
    var memoryTracker = new LocalMemoryTracker();
    final Path firstFile = directory.homePath().resolve("file2");
    StoreChannel storeChannel = fileSystem.write(firstFile);
    PhysicalLogVersionedStoreChannel versionedStoreChannel = new PhysicalLogVersionedStoreChannel(storeChannel, 1, (byte) -1, firstFile, nativeChannelAccessor);
    assertThat(memoryTracker.estimatedHeapMemory()).isZero();
    assertThat(memoryTracker.usedNativeMemory()).isZero();
    try (PhysicalFlushableChannel channel = new PhysicalFlushableChannel(versionedStoreChannel, memoryTracker)) {
        channel.put((byte) 1);
        assertThat(memoryTracker.usedNativeMemory()).isZero();
        assertThat(memoryTracker.estimatedHeapMemory()).isGreaterThan(0);
    }
    assertThat(memoryTracker.estimatedHeapMemory()).isZero();
    assertThat(memoryTracker.usedNativeMemory()).isZero();
}
Also used : Path(java.nio.file.Path) PhysicalFlushableChannel(org.neo4j.io.fs.PhysicalFlushableChannel) LocalMemoryTracker(org.neo4j.memory.LocalMemoryTracker) StoreChannel(org.neo4j.io.fs.StoreChannel) Test(org.junit.jupiter.api.Test)

Aggregations

Path (java.nio.file.Path)6 Test (org.junit.jupiter.api.Test)6 PhysicalFlushableChannel (org.neo4j.io.fs.PhysicalFlushableChannel)6 StoreChannel (org.neo4j.io.fs.StoreChannel)6 InputStream (java.io.InputStream)3 HeapScopedBuffer (org.neo4j.io.memory.HeapScopedBuffer)1 LocalMemoryTracker (org.neo4j.memory.LocalMemoryTracker)1