public static PrimitiveIntSet offHeapIntSet() { return offHeapIntSet( GlobalMemoryTracker.INSTANCE ); }
@Test void trackPrimitiveMemoryAllocations() { LocalMemoryTracker memoryTracker = new LocalMemoryTracker(); PrimitiveIntSet offHeapIntSet = Primitive.offHeapIntSet( memoryTracker ); assertTrue( memoryTracker.usedDirectMemory() > 0 ); offHeapIntSet.close(); assertEquals( 0, memoryTracker.usedDirectMemory() ); }
@Test void convertCollectionToLongArray() { PrimitiveIntSet heapSet = PrimitiveIntCollections.asSet( new int[]{1, 2, 3} ); PrimitiveIntSet offHeapIntSet = Primitive.offHeapIntSet( GlobalMemoryTracker.INSTANCE ); offHeapIntSet.add( 7 ); offHeapIntSet.add( 8 ); assertArrayEquals( new long[]{1, 2, 3}, PrimitiveIntCollections.asLongArray( heapSet ) ); assertArrayEquals( new long[]{7, 8}, PrimitiveIntCollections.asLongArray( offHeapIntSet ) ); }
@Test void trackPrimitiveMemoryOnResize() { LocalMemoryTracker memoryTracker = new LocalMemoryTracker(); PrimitiveIntSet offHeapIntSet = Primitive.offHeapIntSet( memoryTracker ); long originalSetMemory = memoryTracker.usedDirectMemory(); for ( int i = 0; i < Primitive.DEFAULT_OFFHEAP_CAPACITY + 1; i++ ) { offHeapIntSet.add( i ); } assertTrue( memoryTracker.usedDirectMemory() > originalSetMemory ); offHeapIntSet.close(); assertEquals( 0, memoryTracker.usedDirectMemory() ); } }
public static PrimitiveIntSet offHeapIntSet() { return offHeapIntSet( GlobalMemoryTracker.INSTANCE ); }
public static PrimitiveIntSet offHeapIntSet() { return offHeapIntSet( GlobalMemoryTracker.INSTANCE ); }