List of usage examples for java.lang.management MemoryUsage getMax
public long getMax()
From source file:org.toobsframework.management.MemoryMonitor.java
public static void setUsageThreshold(MemoryPoolMXBean memPool, double percentage) { MemoryUsage memUsage = memPool.getUsage(); long max = memUsage.getMax(); memPool.setUsageThreshold((long) (max * percentage)); }
From source file:org.commoncrawl.util.JVMStats.java
public static float getHeapUtilizationRatio() { MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean(); MemoryUsage memHeap = memoryMXBean.getHeapMemoryUsage(); return ((float) memHeap.getUsed()) / ((float) memHeap.getMax()); }
From source file:jef.testbase.JefTester.java
private static void printMem(MemoryUsage m) { System.out.println("??:" + StringUtils.formatSize(m.getMax())); System.out.println("?:" + StringUtils.formatSize(m.getCommitted())); System.out.println("?:" + StringUtils.formatSize(m.getInit())); System.out.println(":" + StringUtils.formatSize(m.getUsed())); }
From source file:org.apache.hadoop.hbase.io.util.HeapMemorySizeUtil.java
/** * @param conf// www .j a v a 2s .c o m * @return The on heap size for L2 block cache. */ public static float getL2BlockCacheHeapPercent(Configuration conf) { float l2CachePercent = 0.0F; String bucketCacheIOEngineName = conf.get(HConstants.BUCKET_CACHE_IOENGINE_KEY, null); // L2 block cache can be on heap when IOEngine is "heap" if (bucketCacheIOEngineName != null && bucketCacheIOEngineName.startsWith("heap")) { float bucketCachePercentage = conf.getFloat(HConstants.BUCKET_CACHE_SIZE_KEY, 0F); MemoryUsage mu = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage(); l2CachePercent = bucketCachePercentage < 1 ? bucketCachePercentage : (bucketCachePercentage * 1024 * 1024) / mu.getMax(); } return l2CachePercent; }
From source file:gridool.util.system.SystemUtils.java
public static long getHeapFreeMemory() { MemoryUsage usage = mbean.getHeapMemoryUsage(); final long max = usage.getMax(); final long used = usage.getUsed(); final long free = max - used; return free;//from w w w . ja v a 2s . c om }
From source file:gridool.util.system.SystemUtils.java
public static float getHeapFreeRatio() { MemoryUsage usage = mbean.getHeapMemoryUsage(); final long max = usage.getMax(); final long used = usage.getUsed(); final long free = max - used; return (float) free / (float) max; }
From source file:org.apache.hadoop.hbase.io.util.MemorySizeUtil.java
/** * Returns the onheap global memstore limit based on the config * 'hbase.regionserver.global.memstore.size'. * @param conf//from www. ja va 2 s. c om * @return the onheap global memstore limt */ public static long getOnheapGlobalMemstoreSize(Configuration conf) { long max = -1L; final MemoryUsage usage = safeGetHeapMemoryUsage(); if (usage != null) { max = usage.getMax(); } float globalMemStorePercent = getGlobalMemStoreHeapPercent(conf, true); return ((long) (max * globalMemStorePercent)); }
From source file:org.apache.hadoop.hbase.io.util.MemorySizeUtil.java
/** * @param conf used to read cache configs * @return the number of bytes to use for LRU, negative if disabled. * @throws IllegalArgumentException if HFILE_BLOCK_CACHE_SIZE_KEY is > 1.0 *//*from www . j a v a 2 s . co m*/ public static long getLruCacheSize(final Configuration conf) { float cachePercentage = conf.getFloat(HConstants.HFILE_BLOCK_CACHE_SIZE_KEY, HConstants.HFILE_BLOCK_CACHE_SIZE_DEFAULT); if (cachePercentage <= 0.0001f) { return -1; } if (cachePercentage > 1.0) { throw new IllegalArgumentException( HConstants.HFILE_BLOCK_CACHE_SIZE_KEY + " must be between 0.0 and 1.0, and not > 1.0"); } long max = -1L; final MemoryUsage usage = safeGetHeapMemoryUsage(); if (usage != null) { max = usage.getMax(); } // Calculate the amount of heap to give the heap. return (long) (max * cachePercentage); }
From source file:org.apache.hadoop.hbase.io.util.MemorySizeUtil.java
/** * @param conf// w w w . j ava 2s . c o m * @return The on heap size for L2 block cache. */ public static float getL2BlockCacheHeapPercent(Configuration conf) { float l2CachePercent = 0.0F; String bucketCacheIOEngineName = conf.get(HConstants.BUCKET_CACHE_IOENGINE_KEY, null); // L2 block cache can be on heap when IOEngine is "heap" if (bucketCacheIOEngineName != null && bucketCacheIOEngineName.startsWith("heap")) { float bucketCachePercentage = conf.getFloat(HConstants.BUCKET_CACHE_SIZE_KEY, 0F); long max = -1L; final MemoryUsage usage = safeGetHeapMemoryUsage(); if (usage != null) { max = usage.getMax(); } l2CachePercent = bucketCachePercentage < 1 ? bucketCachePercentage : (bucketCachePercentage * 1024 * 1024) / max; } return l2CachePercent; }
From source file:org.apache.hadoop.hbase.io.util.MemorySizeUtil.java
/** * @param conf used to read config for bucket cache size. (< 1 is treated as % and > is treated as MiB) * @return the number of bytes to use for bucket cache, negative if disabled. *///from w w w . java2s . co m public static long getBucketCacheSize(final Configuration conf) { final float bucketCachePercentage = conf.getFloat(HConstants.BUCKET_CACHE_SIZE_KEY, 0F); long bucketCacheSize; // Values < 1 are treated as % of heap if (bucketCachePercentage < 1) { long max = -1L; final MemoryUsage usage = safeGetHeapMemoryUsage(); if (usage != null) { max = usage.getMax(); } bucketCacheSize = (long) (max * bucketCachePercentage); // values >= 1 are treated as # of MiB } else { bucketCacheSize = (long) (bucketCachePercentage * 1024 * 1024); } return bucketCacheSize; }