Java Code Examples for io.netty.buffer.PoolArenaMetric#numActiveAllocations()
The following examples show how to use
io.netty.buffer.PoolArenaMetric#numActiveAllocations() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MemoryLeakDetectionRule.java From brpc-java with Apache License 2.0 | 5 votes |
private static int getActiveDirectBuffers(PooledByteBufAllocator alloc) { int directActive = 0, directAlloc = 0, directDealloc = 0; for (PoolArenaMetric arena : alloc.metric().directArenas()) { directActive += arena.numActiveAllocations(); directAlloc += arena.numAllocations(); directDealloc += arena.numDeallocations(); } log.info("direct memory usage, active: {}, alloc: {}, dealloc: {}", directActive, directAlloc, directDealloc); return directActive; }
Example 2
Source File: MemoryLeakDetectionRule.java From brpc-java with Apache License 2.0 | 5 votes |
private static int getActiveHeapBuffers(PooledByteBufAllocator alloc) { int heapActive = 0, heapAlloc = 0, heapDealloc = 0; for (PoolArenaMetric arena : alloc.metric().heapArenas()) { heapActive += arena.numActiveAllocations(); heapAlloc += arena.numAllocations(); heapDealloc += arena.numDeallocations(); } log.info("heap memory usage, active: {}, alloc: {}, dealloc: {}", heapActive, heapAlloc, heapDealloc); return heapActive; }
Example 3
Source File: AllocatorStatsGenerator.java From pulsar with Apache License 2.0 | 5 votes |
private static PoolArenaStats newPoolArenaStats(PoolArenaMetric m) { PoolArenaStats stats = new PoolArenaStats(); stats.numTinySubpages = m.numTinySubpages(); stats.numSmallSubpages = m.numSmallSubpages(); stats.numChunkLists = m.numChunkLists(); stats.tinySubpages = m.tinySubpages().stream() .map(AllocatorStatsGenerator::newPoolSubpageStats) .collect(Collectors.toList()); stats.smallSubpages = m.smallSubpages().stream() .map(AllocatorStatsGenerator::newPoolSubpageStats) .collect(Collectors.toList()); stats.chunkLists = m.chunkLists().stream() .map(AllocatorStatsGenerator::newPoolChunkListStats) .collect(Collectors.toList()); stats.numAllocations = m.numAllocations(); stats.numTinyAllocations = m.numTinyAllocations(); stats.numSmallAllocations = m.numSmallAllocations(); stats.numNormalAllocations = m.numNormalAllocations(); stats.numHugeAllocations = m.numHugeAllocations(); stats.numDeallocations = m.numDeallocations(); stats.numTinyDeallocations = m.numTinyDeallocations(); stats.numSmallDeallocations = m.numSmallDeallocations(); stats.numNormalDeallocations = m.numNormalDeallocations(); stats.numHugeDeallocations = m.numHugeDeallocations(); stats.numActiveAllocations = m.numActiveAllocations(); stats.numActiveTinyAllocations = m.numActiveTinyAllocations(); stats.numActiveSmallAllocations = m.numActiveSmallAllocations(); stats.numActiveNormalAllocations = m.numActiveNormalAllocations(); stats.numActiveHugeAllocations = m.numActiveHugeAllocations(); return stats; }
Example 4
Source File: ManagedLedgerCacheMetrics.java From pulsar with Apache License 2.0 | 4 votes |
@Override public synchronized List<Metrics> generate() { // get the ML cache stats bean ManagedLedgerFactoryMXBean mlCacheStats = getManagedLedgerCacheStats(); Metrics m = createMetrics(); m.put("brk_ml_count", mlCacheStats.getNumberOfManagedLedgers()); m.put("brk_ml_cache_used_size", mlCacheStats.getCacheUsedSize()); m.put("brk_ml_cache_evictions", mlCacheStats.getNumberOfCacheEvictions()); m.put("brk_ml_cache_hits_rate", mlCacheStats.getCacheHitsRate()); m.put("brk_ml_cache_misses_rate", mlCacheStats.getCacheMissesRate()); m.put("brk_ml_cache_hits_throughput", mlCacheStats.getCacheHitsThroughput()); m.put("brk_ml_cache_misses_throughput", mlCacheStats.getCacheMissesThroughput()); PooledByteBufAllocator allocator = EntryCacheImpl.ALLOCATOR; long activeAllocations = 0; long activeAllocationsTiny = 0; long activeAllocationsSmall = 0; long activeAllocationsNormal = 0; long activeAllocationsHuge = 0; long totalAllocated = 0; long totalUsed = 0; for (PoolArenaMetric arena : allocator.metric().directArenas()) { activeAllocations += arena.numActiveAllocations(); activeAllocationsTiny += arena.numActiveTinyAllocations(); activeAllocationsSmall += arena.numActiveSmallAllocations(); activeAllocationsNormal += arena.numActiveNormalAllocations(); activeAllocationsHuge += arena.numActiveHugeAllocations(); for (PoolChunkListMetric list : arena.chunkLists()) { for (PoolChunkMetric chunk : list) { int size = chunk.chunkSize(); int used = size - chunk.freeBytes(); totalAllocated += size; totalUsed += used; } } } m.put("brk_ml_cache_pool_allocated", totalAllocated); m.put("brk_ml_cache_pool_used", totalUsed); m.put("brk_ml_cache_pool_active_allocations", activeAllocations); m.put("brk_ml_cache_pool_active_allocations_tiny", activeAllocationsTiny); m.put("brk_ml_cache_pool_active_allocations_small", activeAllocationsSmall); m.put("brk_ml_cache_pool_active_allocations_normal", activeAllocationsNormal); m.put("brk_ml_cache_pool_active_allocations_huge", activeAllocationsHuge); metrics.clear(); metrics.add(m); return metrics; }