use of org.neo4j.memory.LocalMemoryTracker 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();
}
use of org.neo4j.memory.LocalMemoryTracker in project neo4j by neo4j.
the class TxStateTest method before.
@BeforeEach
void before() {
memoryTracker = new LocalMemoryTracker();
collectionsFactory = spy(collectionsFactorySupplier.create());
state = new TxState(collectionsFactory, memoryTracker);
}
use of org.neo4j.memory.LocalMemoryTracker in project neo4j by neo4j.
the class UnsafeDirectByteBufferFactoryTest method shouldHandleMultipleClose.
@Test
void shouldHandleMultipleClose() {
// given
MemoryTracker tracker = new LocalMemoryTracker();
UnsafeDirectByteBufferAllocator factory = new UnsafeDirectByteBufferAllocator();
// when
factory.allocate(256, tracker);
factory.close();
// then
assertEquals(0, tracker.usedNativeMemory());
factory.close();
assertEquals(0, tracker.usedNativeMemory());
}
use of org.neo4j.memory.LocalMemoryTracker in project neo4j by neo4j.
the class UnsafeDirectByteBufferFactoryTest method shouldFreeOnClose.
@Test
void shouldFreeOnClose() {
// given
MemoryTracker tracker = new LocalMemoryTracker();
try (UnsafeDirectByteBufferAllocator factory = new UnsafeDirectByteBufferAllocator()) {
// when
factory.allocate(256, tracker);
}
// then
assertEquals(0, tracker.usedNativeMemory());
}
use of org.neo4j.memory.LocalMemoryTracker in project neo4j by neo4j.
the class ForsetiMemoryTrackingTest method concurrentMemoryShouldEndUpZero.
@Test
void concurrentMemoryShouldEndUpZero() throws Throwable {
Race race = new Race();
int numThreads = 4;
LocalMemoryTracker[] trackers = new LocalMemoryTracker[numThreads];
for (int i = 0; i < numThreads; i++) {
trackers[i] = new LocalMemoryTracker(memoryPool);
Locks.Client client = forsetiLockManager.newClient();
client.initialize(LeaseService.NoLeaseClient.INSTANCE, 1, trackers[i], Config.defaults());
race.addContestant(new SimulatedTransaction(client));
}
race.go();
for (int i = 0; i < numThreads; i++) {
try (LocalMemoryTracker tracker = trackers[i]) {
assertThat(tracker.estimatedHeapMemory()).describedAs("Tracker " + tracker).isGreaterThanOrEqualTo(0);
}
}
}
Aggregations