當前位置: 首頁>>代碼示例>>Java>>正文


Java MemoryType.NON_HEAP屬性代碼示例

本文整理匯總了Java中java.lang.management.MemoryType.NON_HEAP屬性的典型用法代碼示例。如果您正苦於以下問題:Java MemoryType.NON_HEAP屬性的具體用法?Java MemoryType.NON_HEAP怎麽用?Java MemoryType.NON_HEAP使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在java.lang.management.MemoryType的用法示例。


在下文中一共展示了MemoryType.NON_HEAP屬性的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getMemoryPoolStatsAsString

/**
 * Gets the memory pool statistics from the JVM.
 *
 * @param poolBeans The collection of memory pool beans.
 * @return A string denoting the names and sizes of the memory pools.
 */
public static String getMemoryPoolStatsAsString(List<MemoryPoolMXBean> poolBeans) {
	StringBuilder bld = new StringBuilder("Off-heap pool stats: ");
	int count = 0;
	
	for (MemoryPoolMXBean bean : poolBeans) {
		if (bean.getType() == MemoryType.NON_HEAP) {
			if (count > 0) {
				bld.append(", ");
			}
			count++;

			MemoryUsage usage = bean.getUsage();
			long used = usage.getUsed() >> 20;
			long committed = usage.getCommitted() >> 20;
			long max = usage.getMax() >> 20;
			
			bld.append('[').append(bean.getName()).append(": ");
			bld.append(used).append('/').append(committed).append('/').append(max);
			bld.append(" MB (used/committed/max)]");
		}
	}

	return bld.toString();
}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:30,代碼來源:MemoryLogger.java

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: getType

public MemoryType getType() {
    if (isHeap) {
        return MemoryType.HEAP;
    } else {
        return MemoryType.NON_HEAP;
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:7,代碼來源:MemoryPoolImpl.java

示例9: handleNotification

@Override
public void handleNotification(Notification not, Object handback) {
	
	if (not.getType().equals(MemoryNotificationInfo.MEMORY_THRESHOLD_EXCEEDED)) {
		CompositeDataSupport data=(CompositeDataSupport) not.getUserData();
		
		
		String poolName = (String) data.get("poolName");
		MemoryType type = types.get(poolName);
		if(type==MemoryType.HEAP){
			// clear heap
			aprint.e("Clear heap!");
		}
		else if(type==MemoryType.NON_HEAP) {
			// clear none-heap
			((Config) handback).checkPermGenSpace(false);
		}
		
		/*CompositeDataSupport usage=(CompositeDataSupport) data.get("usage");
		print.e(poolName);
		print.e(types.get(poolName));
		print.e(data.get("count"));
		
		print.e(usage.get("committed"));
		print.e(usage.get("init"));
		print.e(usage.get("max"));
		print.e(usage.get("used"));

		long max=Caster.toLongValue(usage.get("max"),0);
		long used=Caster.toLongValue(usage.get("used"),0);
		long free=max-used;
		print.o("m:"+max);
		print.o("f:"+free);
		print.o("%:"+(100L*used/max));
		//not.*/
	}
	/*
	javax.management.openmbean.CompositeDataSupport(
		compositeType=javax.management.openmbean.CompositeType(
			name=java.lang.management.MemoryUsage,
			items=(
				(itemName=committed,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)),
				(itemName=init,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)),
				(itemName=max,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)),
				(itemName=used,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)))),contents={committed=101580800, init=65404928, max=110362624, used=101085960})

	
	
	javax.management.openmbean.CompositeDataSupport(
			compositeType=javax.management.openmbean.CompositeType(
				name=java.lang.management.MemoryNotificationInfo,
				items=(
						(itemName=count,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)),
						(itemName=poolName,itemType=javax.management.openmbean.SimpleType(name=java.lang.String)),
						(itemName=usage,itemType=javax.management.openmbean.CompositeType(name=java.lang.management.MemoryUsage,items=((itemName=committed,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)),(itemName=init,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)),(itemName=max,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)),(itemName=used,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long))))))),contents={count=1, poolName=CMS Old Gen, usage=javax.management.openmbean.CompositeDataSupport(compositeType=javax.management.openmbean.CompositeType(name=java.lang.management.MemoryUsage,items=((itemName=committed,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)),(itemName=init,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)),(itemName=max,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)),(itemName=used,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)))),contents={committed=101580800, init=65404928, max=110362624, used=101085944})})

	*/
	/*
	print.e(data.getCompositeType());
	print.e(not.getSource().getClass().getName());
	print.e(not.getSource());
	ObjectName on=(ObjectName) not.getSource();
	print.e(on.getKeyPropertyList());
	*/
	
	
	
	/*
	print.e(not.getUserData().getClass().getName());
	print.e(not.getUserData());
	
	print.e(not.getMessage());
	print.e(not.getSequenceNumber());
	print.e(not.getTimeStamp());
	print.e(not.getType());*/
}
 
開發者ID:lucee,項目名稱:Lucee4,代碼行數:76,代碼來源:MemoryNotificationListener.java

示例10: isOffheap

boolean isOffheap() {
  return this.memType == MemoryType.NON_HEAP;
}
 
開發者ID:apache,項目名稱:hbase,代碼行數:3,代碼來源:RegionServerAccounting.java


注:本文中的java.lang.management.MemoryType.NON_HEAP屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。