FreeListManager { void getSlabDescriptions(StringBuilder sb) { for (int i = 0; i < slabs.length; i++) { long startAddr = slabs[i].getMemoryAddress(); long endAddr = startAddr + slabs[i].getSize(); sb.append("[").append(Long.toString(startAddr, 16)).append("..") .append(Long.toString(endAddr, 16)).append("] "); } } FreeListManager(MemoryAllocatorImpl ma, final Slab[] slabs); long getUsedMemory(); long getFreeMemory(); @SuppressWarnings("synthetic-access") OffHeapStoredObject allocate(int size); @SuppressWarnings("synthetic-access") void free(long addr); static final int TINY_MULTIPLE; static final int TINY_FREE_LIST_COUNT; static final int HUGE_MULTIPLE; static final int MAX_TINY; }
@Test public void descriptionOfOneSlab() { Slab chunk = new SlabImpl(10); long address = chunk.getMemoryAddress(); long endAddress = address + 10; this.freeListManager = createFreeListManager(ma, new Slab[] {chunk}); StringBuilder sb = new StringBuilder(); this.freeListManager.getSlabDescriptions(sb); assertThat(sb.toString()) .isEqualTo("[" + Long.toString(address, 16) + ".." + Long.toString(endAddress, 16) + "] "); }