//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void trackPrimitiveMemoryAllocations() internal virtual void TrackPrimitiveMemoryAllocations() { LocalMemoryTracker memoryTracker = new LocalMemoryTracker(); PrimitiveIntSet offHeapIntSet = Primitive.OffHeapIntSet(memoryTracker); assertTrue(memoryTracker.UsedDirectMemory() > 0); offHeapIntSet.Close(); assertEquals(0, memoryTracker.UsedDirectMemory()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldFreeOnClose() internal virtual void ShouldFreeOnClose() { // given MemoryAllocationTracker tracker = new LocalMemoryTracker(); using (UnsafeDirectByteBufferAllocator factory = new UnsafeDirectByteBufferAllocator(tracker)) { // when factory.Allocate(256); } // then assertEquals(0, tracker.UsedDirectMemory()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void trackMemoryAllocations() internal virtual void TrackMemoryAllocations() { LocalMemoryTracker memoryTracker = new LocalMemoryTracker(); GrabAllocator allocator = ( GrabAllocator )MemoryAllocator.createAllocator("2m", memoryTracker); assertEquals(0, memoryTracker.UsedDirectMemory()); long pointer = allocator.AllocateAligned(ByteUnit.mebiBytes(1), 1); assertEquals(ByteUnit.mebiBytes(1), memoryTracker.UsedDirectMemory()); allocator.Close(); assertEquals(0, memoryTracker.UsedDirectMemory()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldHandleMultipleClose() internal virtual void ShouldHandleMultipleClose() { // given MemoryAllocationTracker tracker = new LocalMemoryTracker(); UnsafeDirectByteBufferAllocator factory = new UnsafeDirectByteBufferAllocator(tracker); // when factory.Allocate(256); factory.Close(); // then assertEquals(0, tracker.UsedDirectMemory()); factory.Close(); assertEquals(0, tracker.UsedDirectMemory()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldAllocateBuffer() internal virtual void ShouldAllocateBuffer() { // given MemoryAllocationTracker tracker = new LocalMemoryTracker(); using (UnsafeDirectByteBufferAllocator factory = new UnsafeDirectByteBufferAllocator(tracker)) { // when int bufferSize = 128; factory.Allocate(bufferSize); // then assertEquals(bufferSize, tracker.UsedDirectMemory()); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void trackPrimitiveMemoryOnResize() internal virtual void TrackPrimitiveMemoryOnResize() { LocalMemoryTracker memoryTracker = new LocalMemoryTracker(); PrimitiveIntSet offHeapIntSet = Primitive.OffHeapIntSet(memoryTracker); long originalSetMemory = memoryTracker.UsedDirectMemory(); for (int i = 0; i < Primitive.DefaultOffheapCapacity + 1; i++) { offHeapIntSet.Add(i); } assertTrue(memoryTracker.UsedDirectMemory() > originalSetMemory); offHeapIntSet.Close(); assertEquals(0, memoryTracker.UsedDirectMemory()); }