Example usage for io.netty.buffer UnpooledByteBufAllocator UnpooledByteBufAllocator

List of usage examples for io.netty.buffer UnpooledByteBufAllocator UnpooledByteBufAllocator

Introduction

In this page you can find the example usage for io.netty.buffer UnpooledByteBufAllocator UnpooledByteBufAllocator.

Prototype

public UnpooledByteBufAllocator(boolean preferDirect, boolean disableLeakDetector) 

Source Link

Document

Create a new instance

Usage

From source file:com.heliosapm.utils.buffer.BufferManager.java

License:Apache License

/**
 * Creates a new BufferManager/*from  www .j a  v  a 2s . co  m*/
 */
private BufferManager() {
    leakDetection = getBoolean(ENABLE_LEAK_DETECTION, DEFAULT_LEAK_DETECTION);
    pooledBuffers = getBoolean("buffers.pooled", true);
    directBuffers = getBoolean("buffers.direct", true);
    nHeapArena = getInt("buffers.heaparenas", DEFAULT_NUM_HEAP_ARENA);
    nDirectArena = getInt("buffers.directarenas", DEFAULT_NUM_DIRECT_ARENA);
    pageSize = getInt("buffers.pagesize", DEFAULT_PAGE_SIZE);
    maxOrder = getInt("buffers.maxorder", DEFAULT_MAX_ORDER);
    tinyCacheSize = getInt("buffers.tcachesize", DEFAULT_TINY_CACHE_SIZE);
    smallCacheSize = getInt("buffers.scachesize", DEFAULT_SMALL_CACHE_SIZE);
    normalCacheSize = getInt("buffers.ncachesize", DEFAULT_NORMAL_CACHE_SIZE);
    pooledBufferAllocator = new PooledByteBufAllocator(directBuffers, nHeapArena, nDirectArena, pageSize,
            maxOrder, tinyCacheSize, smallCacheSize, normalCacheSize);
    unpooledBufferAllocator = new UnpooledByteBufAllocator(directBuffers, leakDetection);
    defaultBufferAllocator = pooledBuffers ? pooledBufferAllocator : unpooledBufferAllocator;
    try {
        objectName = new ObjectName(OBJECT_NAME);
        ManagementFactory.getPlatformMBeanServer().registerMBean(this, objectName);
    } catch (Exception ex) {
        System.err
                .println("Failed to register the BufferManager management interface. Continuing without:" + ex);
    }
    directMonitor = new BufferArenaMonitor(pooledBufferAllocator, true);
    heapMonitor = new BufferArenaMonitor(pooledBufferAllocator, false);
    System.out
            .println("Created BufferManager. Pooled: [" + pooledBuffers + "], Direct:[" + directBuffers + "]");
}