当前位置: 首页>>代码示例>>Java>>正文


Java MemoryType.HEAP属性代码示例

本文整理汇总了Java中java.lang.management.MemoryType.HEAP属性的典型用法代码示例。如果您正苦于以下问题:Java MemoryType.HEAP属性的具体用法?Java MemoryType.HEAP怎么用?Java MemoryType.HEAP使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在java.lang.management.MemoryType的用法示例。


在下文中一共展示了MemoryType.HEAP属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isTenured

/**
 * Determines if the name of the memory pool MXBean provided matches a list of known tenured pool
 * names.
 * 
 * Package private for testing.
 * 
 * @param memoryPoolMXBean The memory pool MXBean to check.
 * @return True if the pool name matches a known tenured pool name, false otherwise.
 */
static boolean isTenured(MemoryPoolMXBean memoryPoolMXBean) {
  if (memoryPoolMXBean.getType() != MemoryType.HEAP) {
    return false;
  }

  String name = memoryPoolMXBean.getName();

  return name.equals("CMS Old Gen") // Sun Concurrent Mark Sweep GC
      || name.equals("PS Old Gen") // Sun Parallel GC
      || name.equals("G1 Old Gen") // Sun G1 GC
      || name.equals("Old Space") // BEA JRockit 1.5, 1.6 GC
      || name.equals("Tenured Gen") // Hitachi 1.5 GC
      || name.equals("Java heap") // IBM 1.5, 1.6 GC
      || name.equals("GenPauseless Old Gen") // azul C4/GPGC collector

      // Allow an unknown pool name to monitor
      || (HEAP_POOL != null && name.equals(HEAP_POOL));
}
 
开发者ID:ampool,项目名称:monarch,代码行数:27,代码来源:HeapMemoryMonitor.java

示例2: isTenured

/**
 * Determines if the name of the memory pool MXBean provided matches a list of
 * known tenured pool names.
 * 
 * Package private for testing.
 * 
 * @param memoryPoolMXBean
 *          The memory pool MXBean to check.
 * @return True if the pool name matches a known tenured pool name, false
 *         otherwise.
 */
static boolean isTenured(MemoryPoolMXBean memoryPoolMXBean) {
  if (memoryPoolMXBean.getType() != MemoryType.HEAP) {
    return false;
  }
  
  String name = memoryPoolMXBean.getName();
  
  return name.equals("CMS Old Gen")     // Sun Concurrent Mark Sweep GC
      || name.equals("PS Old Gen")      // Sun Parallel GC
      || name.equals("G1 Old Gen")      // Sun G1 GC
      || name.equals("Old Space")       // BEA JRockit 1.5, 1.6 GC
      || name.equals("Tenured Gen")     // Hitachi 1.5 GC
      || name.equals("Java heap")       // IBM 1.5, 1.6 GC
      
      // Allow an unknown pool name to monitor
      || (HEAP_POOL != null && name.equals(HEAP_POOL));
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:28,代码来源:HeapMemoryMonitor.java

示例3: isEden

/**
 * 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));
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:24,代码来源:HeapMemoryMonitor.java

示例4: getMemoryBean

private static MemoryPoolMXBean getMemoryBean(){
  System.gc();

  List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans();
  long curMax = 0;
  MemoryPoolMXBean heap = null;
  
  for (MemoryPoolMXBean pool : pools) {
    if (pool.getType() != MemoryType.HEAP) {
      continue;
    }
    MemoryUsage memusage = pool.getUsage();
    long max = memusage.getMax();
    if(max > curMax)
      heap = pool;
  }
  return heap;
}
 
开发者ID:teanalab,项目名称:demidovii,代码行数:18,代码来源:MemoryChecker.java

示例5: reportPeakMemoryUsage

public static void reportPeakMemoryUsage() {
  List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans();
  long totalHeap = 0;
  long totalNonHeap = 0;
  long gcTime = 0;
  for (MemoryPoolMXBean memoryPoolMXBean : pools) {
    long peakUsed = memoryPoolMXBean.getPeakUsage().getUsed();
    if (memoryPoolMXBean.getType() == MemoryType.HEAP) {
      totalHeap += peakUsed;
    } else if (memoryPoolMXBean.getType() == MemoryType.NON_HEAP) {
      totalNonHeap += peakUsed;
    }
  }
  for (GarbageCollectorMXBean garbageCollectorMXBean : ManagementFactory.getGarbageCollectorMXBeans()) {
    gcTime += garbageCollectorMXBean.getCollectionTime();
  }
  VM.println("[Memstat] Heap: " + totalHeap + "B\tNonHeap: " + totalNonHeap
      + "B\tCollected: " + collectedMemory + "B\tGC-Time: " + gcTime + "ms");
}
 
开发者ID:smarr,项目名称:SOMns,代码行数:19,代码来源:ActorExecutionTrace.java

示例6: init

public synchronized static void init(ConfigServer cs){
      if(init) return;
		// set level
      for (MemoryPoolMXBean pool : ManagementFactory.getMemoryPoolMXBeans()) {
    	  types.put(pool.getName(), pool.getType());
        // 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()) {
    		  long maxMemory = pool.getUsage().getMax();
    		  long warningThreshold = (long) (maxMemory * 0.9);
    		  //long warningThreshold = maxMemory -(10*1024*1024);
    		  pool.setUsageThreshold(warningThreshold);
    	  }
      }
      
      MemoryMXBean mbean = ManagementFactory.getMemoryMXBean();
      NotificationEmitter emitter = (NotificationEmitter) mbean;
      MemoryNotificationListener listener = new MemoryNotificationListener(types);
      emitter.addNotificationListener(listener, null, cs);
      init=true;
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:21,代码来源:MemoryControler.java

示例7: getMemoryUsageAsStruct

public static Struct getMemoryUsageAsStruct(int type) {
	java.util.List<MemoryPoolMXBean> manager = ManagementFactory.getMemoryPoolMXBeans();
	Iterator<MemoryPoolMXBean> it = manager.iterator();
	
	MemoryPoolMXBean bean;
	MemoryUsage usage;
	MemoryType _type;
	long used=0,max=0,init=0;
	while(it.hasNext()){
		bean = it.next();
		usage = bean.getUsage();
		_type = bean.getType();
		if((type==MEMORY_TYPE_HEAP && _type==MemoryType.HEAP) || (type==MEMORY_TYPE_NON_HEAP && _type==MemoryType.NON_HEAP)){
			used+=usage.getUsed();
			max+=usage.getMax();
			init+=usage.getInit();
		}
	}
	Struct sct=new StructImpl();
	sct.setEL(KeyConstants._used, Caster.toDouble(used));
	sct.setEL(KeyConstants._max, Caster.toDouble(max));
	sct.setEL(KeyConstants._init, Caster.toDouble(init));
	sct.setEL(KeyImpl.init("available"), Caster.toDouble(max-used));
	return sct;
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:25,代码来源:SystemUtil.java

示例8: getMemoryUsageCompact

public static Struct getMemoryUsageCompact(int type) {
	java.util.List<MemoryPoolMXBean> manager = ManagementFactory.getMemoryPoolMXBeans();
	Iterator<MemoryPoolMXBean> it = manager.iterator();
	
	MemoryPoolMXBean bean;
	MemoryUsage usage;
	MemoryType _type;
	Struct sct=new StructImpl();
	while(it.hasNext()){
		bean = it.next();
		usage = bean.getUsage();
		_type = bean.getType();
		if(type==MEMORY_TYPE_HEAP && _type!=MemoryType.HEAP)continue;
		if(type==MEMORY_TYPE_NON_HEAP && _type!=MemoryType.NON_HEAP)continue;
			
		double d=((int)(100D/usage.getMax()*usage.getUsed()))/100D;
		sct.setEL(KeyImpl.init(bean.getName()), Caster.toDouble(d));
	}
	return sct;
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:20,代码来源:SystemUtil.java

示例9: getMemoryUsageAsStruct

public static Struct getMemoryUsageAsStruct(int type) {
	java.util.List<MemoryPoolMXBean> manager = ManagementFactory.getMemoryPoolMXBeans();
	Iterator<MemoryPoolMXBean> it = manager.iterator();

	MemoryPoolMXBean bean;
	MemoryUsage usage;
	MemoryType _type;
	long used = 0, max = 0, init = 0;
	while(it.hasNext()) {
		bean = it.next();
		usage = bean.getUsage();
		_type = bean.getType();
		if((type == MEMORY_TYPE_HEAP && _type == MemoryType.HEAP) || (type == MEMORY_TYPE_NON_HEAP && _type == MemoryType.NON_HEAP)) {
			used += usage.getUsed();
			max += usage.getMax();
			init += usage.getInit();
		}
	}
	Struct sct = new StructImpl();
	sct.setEL(KeyConstants._used, Caster.toDouble(used));
	sct.setEL(KeyConstants._max, Caster.toDouble(max));
	sct.setEL(KeyConstants._init, Caster.toDouble(init));
	sct.setEL(KeyImpl.init("available"), Caster.toDouble(max - used));
	return sct;
}
 
开发者ID:lucee,项目名称:Lucee,代码行数:25,代码来源:SystemUtil.java

示例10: getMemoryUsageCompact

public static Struct getMemoryUsageCompact(int type) {
	java.util.List<MemoryPoolMXBean> manager = ManagementFactory.getMemoryPoolMXBeans();
	Iterator<MemoryPoolMXBean> it = manager.iterator();

	MemoryPoolMXBean bean;
	MemoryUsage usage;
	MemoryType _type;
	Struct sct = new StructImpl();
	while(it.hasNext()) {
		bean = it.next();
		usage = bean.getUsage();
		_type = bean.getType();
		if(type == MEMORY_TYPE_HEAP && _type != MemoryType.HEAP)
			continue;
		if(type == MEMORY_TYPE_NON_HEAP && _type != MemoryType.NON_HEAP)
			continue;

		double d = ((int)(100D / usage.getMax() * usage.getUsed())) / 100D;
		sct.setEL(KeyImpl.init(bean.getName()), Caster.toDouble(d));
	}
	return sct;
}
 
开发者ID:lucee,项目名称:Lucee,代码行数:22,代码来源:SystemUtil.java

示例11: isAboveLowWaterMark

/**
 * 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 (getGlobalMemStoreDataSize() >= globalMemStoreLimitLowMark) {
      // Indicates that the offheap memstore's data 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;
}
 
开发者ID:apache,项目名称:hbase,代码行数:23,代码来源:RegionServerAccounting.java

示例12: getGlobalMemStoreSize

/**
 * @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);
}
 
开发者ID:apache,项目名称:hbase,代码行数:24,代码来源:MemorySizeUtil.java

示例13: getMemoryUsage

private MemoryUsage getMemoryUsage(MemoryType type) {
    if (type == MemoryType.HEAP) {
        return ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
    } else {
        return ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:7,代码来源:JvmMemoryImpl.java

示例14: getType

public MemoryType getType() {
    if (isHeap) {
        return MemoryType.HEAP;
    } else {
        return MemoryType.NON_HEAP;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:7,代码来源:MemoryPoolImpl.java

示例15: findPool

private static MemoryPoolMXBean findPool()
{
	MemoryPoolMXBean ret = null;
	for (MemoryPoolMXBean pool : ManagementFactory.getMemoryPoolMXBeans()) {
		if (pool.getType() == MemoryType.HEAP && pool.isUsageThresholdSupported()) {
			ret = pool;
		}
	}
	// we do something when we reached 99.9% of memory usage
	// when we get to this point gc was unable to recover memory.
	ret.setCollectionUsageThreshold((long) Math.floor(ret.getUsage().getMax() * 0.999));

	return (ret);
}
 
开发者ID:quqiangsheng,项目名称:abhot,代码行数:14,代码来源:MemoryMonitor.java


注:本文中的java.lang.management.MemoryType.HEAP属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。