Java Code Examples for java.lang.management.MemoryType#HEAP
The following examples show how to use
java.lang.management.MemoryType#HEAP .
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: RegionServerAccounting.java From hbase with Apache License 2.0 | 6 votes |
/** * Return true if we're above the low watermark */ public FlushType isAboveLowWaterMark() { // for onheap memstore we check if the global memstore size and the // global heap overhead is greater than the global memstore lower mark limit if (memType == MemoryType.HEAP) { if (getGlobalMemStoreHeapSize() >= globalMemStoreLimitLowMark) { return FlushType.ABOVE_ONHEAP_LOWER_MARK; } } else { if (getGlobalMemStoreOffHeapSize() >= globalMemStoreLimitLowMark) { // Indicates that the offheap memstore's size is greater than the global memstore // lower limit return FlushType.ABOVE_OFFHEAP_LOWER_MARK; } else if (getGlobalMemStoreHeapSize() >= globalOnHeapMemstoreLimitLowMark) { // Indicates that the offheap memstore's heap overhead is greater than the global memstore // onheap lower limit return FlushType.ABOVE_ONHEAP_LOWER_MARK; } } return FlushType.NORMAL; }
Example 2
Source File: MemorySizeUtil.java From hbase with Apache License 2.0 | 6 votes |
/** * @return Pair of global memstore size and memory type(ie. on heap or off heap). */ public static Pair<Long, MemoryType> getGlobalMemStoreSize(Configuration conf) { long offheapMSGlobal = conf.getLong(OFFHEAP_MEMSTORE_SIZE_KEY, 0);// Size in MBs if (offheapMSGlobal > 0) { // Off heap memstore size has not relevance when MSLAB is turned OFF. We will go with making // this entire size split into Chunks and pooling them in MemstoreLABPoool. We dont want to // create so many on demand off heap chunks. In fact when this off heap size is configured, we // will go with 100% of this size as the pool size if (MemStoreLAB.isEnabled(conf)) { // We are in offheap Memstore use long globalMemStoreLimit = (long) (offheapMSGlobal * 1024 * 1024); // Size in bytes return new Pair<>(globalMemStoreLimit, MemoryType.NON_HEAP); } else { // Off heap max memstore size is configured with turning off MSLAB. It makes no sense. Do a // warn log and go with on heap memstore percentage. By default it will be 40% of Xmx LOG.warn("There is no relevance of configuring '" + OFFHEAP_MEMSTORE_SIZE_KEY + "' when '" + MemStoreLAB.USEMSLAB_KEY + "' is turned off." + " Going with on heap global memstore size ('" + MEMSTORE_SIZE_KEY + "')"); } } return new Pair<>(getOnheapGlobalMemStoreSize(conf), MemoryType.HEAP); }
Example 3
Source File: RangerMetricsUtil.java From ranger with Apache License 2.0 | 6 votes |
/** * collect the pool division of java */ protected Map<String, Object> getPoolDivision() { if (LOG.isDebugEnabled()) { LOG.debug("==> RangerJVMMetricUtil.getPoolDivision()"); } Map<String, Object> poolDivisionValues = new LinkedHashMap<>(); for (MemoryPoolMXBean mpBean : ManagementFactory.getMemoryPoolMXBeans()) { if (mpBean.getType() == MemoryType.HEAP) { poolDivisionValues.put(mpBean.getName(), mpBean.getUsage()); } } if (LOG.isDebugEnabled()) { LOG.debug("<== RangerJVMMetricUtil.getPoolDivision()" + poolDivisionValues); } return poolDivisionValues; }
Example 4
Source File: HeapMonitorThread.java From dremio-oss with Apache License 2.0 | 6 votes |
private void registerForNotifications() { // Register the listener with MemoryMXBean NotificationEmitter emitter = (NotificationEmitter) ManagementFactory.getMemoryMXBean(); emitter.addNotificationListener(listener, null, null); // set collection usage threshold. for (MemoryPoolMXBean pool : ManagementFactory.getMemoryPoolMXBeans()) { if (pool.getType() == MemoryType.HEAP && pool.isUsageThresholdSupported() && pool.isCollectionUsageThresholdSupported()) { long threshold = (pool.getUsage().getMax() * thresholdPercentage) / 100; logger.info("setting collection threshold for " + pool.getName() + " with max " + pool.getUsage().getMax() + " to " + threshold); pool.setCollectionUsageThreshold(threshold); monitoredPools.put(pool.getName(), pool.getCollectionUsageThresholdCount()); } else { logger.info("skip monitoring for pool " + pool.getName()); } } }
Example 5
Source File: HeapMemoryMonitor.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
/** * Determines if the name of the memory pool MXBean provided matches a list of * known young generation pool names. * * @param memoryPoolMXBean * The memory pool MXBean to check. * @return True if the pool name matches a known young generation pool name, * false otherwise. */ static boolean isEden(MemoryPoolMXBean memoryPoolMXBean) { if (memoryPoolMXBean.getType() != MemoryType.HEAP) { return false; } String name = memoryPoolMXBean.getName(); return name.equals("Par Eden Space") // Oracle ParNew with Concurrent Mark Sweep GC || name.equals("PS Eden Space") // Oracle Parallel GC || name.equals("G1 Eden") // Oracle G1 GC //|| name.equals("Nursery") // BEA JRockit 1.5, 1.6 GC || name.equals("Eden Space") // Hitachi 1.5 GC // Allow an unknown pool name to monitor || (HEAP_EDEN_POOL != null && name.equals(HEAP_EDEN_POOL)); }
Example 6
Source File: MemoryWarningSystem.java From metafacture-core with Apache License 2.0 | 5 votes |
/** * Tenured Space Pool can be determined by it being of type HEAP and by it * being possible to set the usage threshold. * * @return MXBean for the Tenured Space Pool */ private static MemoryPoolMXBean findTenuredGenPool() { // I don't know whether this approach is better, or whether // we should rather check for the pool name "Tenured Gen"? for (final MemoryPoolMXBean pool : ManagementFactory.getMemoryPoolMXBeans()) if (pool.getType() == MemoryType.HEAP && pool.isUsageThresholdSupported()) { return pool; } throw new AssertionError("Could not find tenured space"); }
Example 7
Source File: MemoryPoolImpl.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public MemoryType getType() { if (isHeap) { return MemoryType.HEAP; } else { return MemoryType.NON_HEAP; } }
Example 8
Source File: JvmMemoryImpl.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private MemoryUsage getMemoryUsage(MemoryType type) { if (type == MemoryType.HEAP) { return ManagementFactory.getMemoryMXBean().getHeapMemoryUsage(); } else { return ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage(); } }
Example 9
Source File: MemoryPoolImpl.java From hottub with GNU General Public License v2.0 | 5 votes |
public MemoryType getType() { if (isHeap) { return MemoryType.HEAP; } else { return MemoryType.NON_HEAP; } }
Example 10
Source File: MemoryWarningService.java From maven-framework-project with MIT License | 5 votes |
/** * Tenured Space Pool can be determined by it being of type HEAP and by it * being possible to set the usage threshold. */ private static MemoryPoolMXBean findTenuredGenPool() { for (MemoryPoolMXBean pool : ManagementFactory.getMemoryPoolMXBeans()) { // I don't know whether this approach is better, or whether // we should rather check for the pool name "Tenured Gen"? if (pool.getType() == MemoryType.HEAP && pool.isUsageThresholdSupported()) { return pool; } } throw new AssertionError("Could not find tenured space"); }
Example 11
Source File: HeapMemoryMonitor.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * Determines if the name of the memory pool MXBean provided matches a list of * known survivor space pool names. * * @param memoryPoolMXBean * The memory pool MXBean to check. * @return True if the pool name matches a known survivor space pool name, * false otherwise. */ static boolean isSurvivor(MemoryPoolMXBean memoryPoolMXBean) { if (memoryPoolMXBean.getType() != MemoryType.HEAP) { return false; } String name = memoryPoolMXBean.getName(); return name.equals("Par Survivor Space") // Oracle Concurrent Mark Sweep GC || name.equals("PS Survivor Space") // Oracle Parallel GC || name.equals("G1 Survivor") // Oracle G1 GC || name.equals("Survivor Space") // Hitachi 1.5 GC // Allow an unknown pool name to monitor || (HEAP_SURVIVOR_POOL != null && name.equals(HEAP_SURVIVOR_POOL)); }
Example 12
Source File: JvmMemoryImpl.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private MemoryUsage getMemoryUsage(MemoryType type) { if (type == MemoryType.HEAP) { return ManagementFactory.getMemoryMXBean().getHeapMemoryUsage(); } else { return ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage(); } }
Example 13
Source File: JvmMemoryImpl.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private MemoryUsage getMemoryUsage(MemoryType type) { if (type == MemoryType.HEAP) { return ManagementFactory.getMemoryMXBean().getHeapMemoryUsage(); } else { return ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage(); } }
Example 14
Source File: AtlasMetricJVMUtil.java From atlas with Apache License 2.0 | 5 votes |
/** * collect the pool division of java */ private static void pooldivision(Map<String, Object> memory) { Map<String, Object> poolDivisionValues = new LinkedHashMap<>(); for (MemoryPoolMXBean mpBean : ManagementFactory.getMemoryPoolMXBeans()) { if (mpBean.getType() == MemoryType.HEAP) { poolDivisionValues.put(mpBean.getName(), mpBean.getUsage()); } } memory.put("memory_pool_usages", poolDivisionValues); }
Example 15
Source File: MemoryMonitor.java From rice with Educational Community License v2.0 | 5 votes |
private static MemoryPoolMXBean findTenuredGenPool() { for (MemoryPoolMXBean pool : ManagementFactory.getMemoryPoolMXBeans()) { if (pool.getType() == MemoryType.HEAP && pool.isUsageThresholdSupported()) { return pool; } } throw new AssertionError("could not find tenured space"); }
Example 16
Source File: JvmMemoryImpl.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private MemoryUsage getMemoryUsage(MemoryType type) { if (type == MemoryType.HEAP) { return ManagementFactory.getMemoryMXBean().getHeapMemoryUsage(); } else { return ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage(); } }
Example 17
Source File: RegionServerAccounting.java From hbase with Apache License 2.0 | 5 votes |
void setGlobalMemStoreLimits(long newGlobalMemstoreLimit) { if (this.memType == MemoryType.HEAP) { this.globalMemStoreLimit = newGlobalMemstoreLimit; this.globalMemStoreLimitLowMark = (long) (this.globalMemStoreLimit * this.globalMemStoreLimitLowMarkPercent); } else { this.globalOnHeapMemstoreLimit = newGlobalMemstoreLimit; this.globalOnHeapMemstoreLimitLowMark = (long) (this.globalOnHeapMemstoreLimit * this.globalMemStoreLimitLowMarkPercent); } }
Example 18
Source File: JvmMemoryImpl.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private MemoryUsage getMemoryUsage(MemoryType type) { if (type == MemoryType.HEAP) { return ManagementFactory.getMemoryMXBean().getHeapMemoryUsage(); } else { return ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage(); } }
Example 19
Source File: MemoryPoolImpl.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public MemoryType getType() { if (isHeap) { return MemoryType.HEAP; } else { return MemoryType.NON_HEAP; } }
Example 20
Source File: MemoryPoolImpl.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public MemoryType getType() { if (isHeap) { return MemoryType.HEAP; } else { return MemoryType.NON_HEAP; } }