use of com.ctrip.xpipe.testutils.MemoryPrinter in project x-pipe by ctripcorp.
the class ByteArrayOutputStreamPayloadTest method testNewHeap.
@Test
public void testNewHeap() throws Exception {
final MemoryPrinter memoryPrinter = new MemoryPrinter(scheduled);
memoryPrinter.printMemory();
final int length = 1 << 10;
int concurrentCount = 10;
final CountDownLatch latch = new CountDownLatch(concurrentCount);
final ByteBuf byteBuf = directByteBuf(length);
byteBuf.writeBytes(randomString(length).getBytes());
byte[] dst = new byte[length];
byteBuf.readBytes(dst);
memoryPrinter.printMemory();
for (int i = 0; i < concurrentCount; i++) {
Thread current = new Thread(new AbstractExceptionLogTask() {
@Override
protected void doRun() throws Exception {
try {
byteBuf.readerIndex(0);
ByteArrayOutputStream baous = new ByteArrayOutputStream();
byteBuf.readBytes(baous, length);
} finally {
latch.countDown();
}
}
});
current.start();
memoryPrinter.printMemory();
}
latch.await();
}
use of com.ctrip.xpipe.testutils.MemoryPrinter in project x-pipe by ctripcorp.
the class AbstractMetaServerTest method beforeAbstractMetaServerTest.
@Before
public void beforeAbstractMetaServerTest() throws Exception {
memoryPrinter = new MemoryPrinter(scheduled, 500);
memoryPrinter.start();
}
Aggregations