java.lang.management.MemoryType#HEAP源码实例Demo

下面列出了java.lang.management.MemoryType#HEAP 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: hbase   文件: MemorySizeUtil.java
/**
 * @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);
}
 
源代码2 项目: ranger   文件: RangerMetricsUtil.java
/**
 * 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;
}
 
源代码3 项目: gemfirexd-oss   文件: HeapMemoryMonitor.java
/**
 * 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));
}
 
源代码4 项目: dremio-oss   文件: HeapMonitorThread.java
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());
    }
  }
}
 
源代码5 项目: hbase   文件: RegionServerAccounting.java
/**
 * 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;
}
 
源代码6 项目: dragonwell8_jdk   文件: JvmMemoryImpl.java
private MemoryUsage getMemoryUsage(MemoryType type) {
    if (type == MemoryType.HEAP) {
        return ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
    } else {
        return ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage();
    }
}
 
源代码7 项目: dragonwell8_jdk   文件: MemoryPoolImpl.java
public MemoryType getType() {
    if (isHeap) {
        return MemoryType.HEAP;
    } else {
        return MemoryType.NON_HEAP;
    }
}
 
源代码8 项目: openjdk-8   文件: MemoryPoolImpl.java
public MemoryType getType() {
    if (isHeap) {
        return MemoryType.HEAP;
    } else {
        return MemoryType.NON_HEAP;
    }
}
 
源代码9 项目: TencentKona-8   文件: JvmMemoryImpl.java
private MemoryUsage getMemoryUsage(MemoryType type) {
    if (type == MemoryType.HEAP) {
        return ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
    } else {
        return ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage();
    }
}
 
源代码10 项目: hbase   文件: RegionServerAccounting.java
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);
  }
}
 
源代码11 项目: openjdk-8   文件: JvmMemoryImpl.java
private MemoryUsage getMemoryUsage(MemoryType type) {
    if (type == MemoryType.HEAP) {
        return ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
    } else {
        return ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage();
    }
}
 
源代码12 项目: rice   文件: MemoryMonitor.java
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");
}
 
源代码13 项目: atlas   文件: AtlasMetricJVMUtil.java
/**
 * 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);
}
 
源代码14 项目: metafacture-core   文件: MemoryWarningSystem.java
/**
 * 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");
}
 
源代码15 项目: jdk8u-jdk   文件: JvmMemoryImpl.java
private MemoryUsage getMemoryUsage(MemoryType type) {
    if (type == MemoryType.HEAP) {
        return ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
    } else {
        return ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage();
    }
}
 
源代码16 项目: gemfirexd-oss   文件: HeapMemoryMonitor.java
/**
 * 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));
}
 
/**
 * 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");
}
 
源代码18 项目: hottub   文件: MemoryPoolImpl.java
public MemoryType getType() {
    if (isHeap) {
        return MemoryType.HEAP;
    } else {
        return MemoryType.NON_HEAP;
    }
}
 
源代码19 项目: openjdk-8-source   文件: JvmMemoryImpl.java
private MemoryUsage getMemoryUsage(MemoryType type) {
    if (type == MemoryType.HEAP) {
        return ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
    } else {
        return ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage();
    }
}
 
源代码20 项目: openjdk-8-source   文件: MemoryPoolImpl.java
public MemoryType getType() {
    if (isHeap) {
        return MemoryType.HEAP;
    } else {
        return MemoryType.NON_HEAP;
    }
}
 
 同类方法