private void assertOperatorMemoryAllocations( MemoryTrackingContext memoryTrackingContext, long expectedUserMemory, long expectedSystemMemory, long expectedRevocableMemory) { assertEquals(memoryTrackingContext.getUserMemory(), expectedUserMemory, "User memory verification failed"); // both user and system memory are allocated from the same memoryPool assertEquals(memoryPool.getReservedBytes(), expectedUserMemory + expectedSystemMemory, "Memory pool verification failed"); assertEquals(memoryTrackingContext.getSystemMemory(), expectedSystemMemory, "System memory verification failed"); assertEquals(memoryTrackingContext.getRevocableMemory(), expectedRevocableMemory, "Revocable memory verification failed"); }
@Test public void testNotifyListenerOnMemoryReserved() { setupConsumeRevocableMemory(ONE_BYTE, 10); AtomicReference<MemoryPool> notifiedPool = new AtomicReference<>(); AtomicLong notifiedBytes = new AtomicLong(); userPool.addListener(MemoryPoolListener.onMemoryReserved(pool -> { notifiedPool.set(pool); notifiedBytes.set(pool.getReservedBytes()); })); userPool.reserve(fakeQueryId, "test", 3); assertEquals(notifiedPool.get(), userPool); assertEquals(notifiedBytes.get(), 3L); }
private void assertLocalMemoryAllocations( MemoryTrackingContext memoryTrackingContext, long expectedPoolMemory, long expectedContextUserMemory, long expectedContextSystemMemory) { assertEquals(memoryTrackingContext.getUserMemory(), expectedContextUserMemory, "User memory verification failed"); assertEquals(memoryPool.getReservedBytes(), expectedPoolMemory, "Memory pool verification failed"); assertEquals(memoryTrackingContext.localSystemMemoryContext().getBytes(), expectedContextSystemMemory, "Local system memory verification failed"); } }
MemoryPool general = server.getLocalMemoryManager().getGeneralPool(); assertFalse(reserved.isPresent()); assertTrue(general.getReservedBytes() > 0);
memoryPool.free(QUERY_ID, "test", memoryPool.getReservedBytes());
MemoryPool general = server.getLocalMemoryManager().getGeneralPool(); assertFalse(reserved.isPresent()); assertTrue(general.getReservedBytes() > 0);