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


Java MemoryType類代碼示例

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


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

示例1: isTenured

import java.lang.management.MemoryType; //導入依賴的package包/類
/**
 * 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,代碼行數:28,代碼來源:HeapMemoryMonitor.java

示例2: initCodeSizeLimits

import java.lang.management.MemoryType; //導入依賴的package包/類
public static void initCodeSizeLimits(int nMaxSizeMemPoolCodeCache, int nMaxSizeMemPoolPermGen)
{
	// PJD remove ibm JMV
	List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans();
	for (MemoryPoolMXBean p: pools)
	{
		if(p.getType().compareTo(MemoryType.NON_HEAP) == 0)
		{
			String cs = p.getName();
			if(cs.equalsIgnoreCase("Code Cache"))
				p.setUsageThreshold((long)nMaxSizeMemPoolCodeCache * 1024L * 1024L);
			else if(cs.equalsIgnoreCase("Perm Gen"))
				p.setUsageThreshold((long)nMaxSizeMemPoolPermGen * 1024L * 1024L);
		}
	}
}
 
開發者ID:costea7,項目名稱:ChronoBike,代碼行數:17,代碼來源:CodeManager.java

示例3: setMemThreshold

import java.lang.management.MemoryType; //導入依賴的package包/類
private void setMemThreshold()
{
	m_bMaxPermanentHeap_MoSet = false;

	List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans();
	for (MemoryPoolMXBean p: pools)
	{
		if(p.getType().compareTo(MemoryType.HEAP) == 0)
		{
			String cs = p.getName();
			if(cs.equalsIgnoreCase("Tenured gen"))
			{
				long l = 1024L * 1024L * (long)m_nMaxPermanentHeap_Mo;
				p.setUsageThreshold(l);
				m_tenuredPool = p;
			}				
		}
	}
}
 
開發者ID:costea7,項目名稱:ChronoBike,代碼行數:20,代碼來源:ThreadStatementGC.java

示例4: poolSummaries

import java.lang.management.MemoryType; //導入依賴的package包/類
/**
 * Returns a summary information about the memory pools.
 */
public static String poolSummaries() {
    // Why ? list-archive?4273859
    // How ? http://stackoverflow.com/questions/697336/how-do-i-programmatically-find-out-my-permgen-space-usage
    //       http://stackoverflow.com/questions/8356416/xxmaxpermsize-with-or-without-xxpermsize
    StringBuilder sb = new StringBuilder();
    Iterator<MemoryPoolMXBean> iter =
            ManagementFactory.getMemoryPoolMXBeans().iterator();
    while (iter.hasNext()) {
        MemoryPoolMXBean item = iter.next();
        String name = item.getName();
        MemoryType type = item.getType();
        MemoryUsage usage = item.getUsage();
        MemoryUsage peak = item.getPeakUsage();
        MemoryUsage collections = item.getCollectionUsage();
        sb.append(String.format("Memory pool name: " + name
                                + ", type: " + type
                                + ", usage: " + usage
                                + ", peak: " + peak
                                + ", collections: " + collections
                                + "\n"));
    }
    return sb.toString();
}
 
開發者ID:aws,項目名稱:aws-sdk-java-v2,代碼行數:27,代碼來源:Memory.java

示例5: isTenured

import java.lang.management.MemoryType; //導入依賴的package包/類
/**
 * 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,代碼行數:29,代碼來源:HeapMemoryMonitor.java

示例6: isEden

import java.lang.management.MemoryType; //導入依賴的package包/類
/**
 * 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,代碼行數:25,代碼來源:HeapMemoryMonitor.java

示例7: getMemoryBean

import java.lang.management.MemoryType; //導入依賴的package包/類
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,代碼行數:19,代碼來源:MemoryChecker.java

示例8: getMemoryPoolStatsAsString

import java.lang.management.MemoryType; //導入依賴的package包/類
/**
 * 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,代碼行數:31,代碼來源:MemoryLogger.java

示例9: reportPeakMemoryUsage

import java.lang.management.MemoryType; //導入依賴的package包/類
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,代碼行數:20,代碼來源:ActorExecutionTrace.java

示例10: init

import java.lang.management.MemoryType; //導入依賴的package包/類
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,代碼行數:22,代碼來源:MemoryControler.java

示例11: getMemoryUsageAsStruct

import java.lang.management.MemoryType; //導入依賴的package包/類
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,代碼行數:26,代碼來源:SystemUtil.java

示例12: getMemoryUsageCompact

import java.lang.management.MemoryType; //導入依賴的package包/類
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,代碼行數:21,代碼來源:SystemUtil.java

示例13: getMemoryUsageAsStruct

import java.lang.management.MemoryType; //導入依賴的package包/類
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,代碼行數:26,代碼來源:SystemUtil.java

示例14: getMemoryUsageCompact

import java.lang.management.MemoryType; //導入依賴的package包/類
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,代碼行數:23,代碼來源:SystemUtil.java

示例15: testReadWriteObject

import java.lang.management.MemoryType; //導入依賴的package包/類
public void testReadWriteObject() throws Exception {
    checkBasicReadWriteObject(Boolean.TRUE, "java.lang.Boolean:true\n");
    checkBasicReadWriteObject(Byte.valueOf("1"), "java.lang.Byte:1\n");
    checkBasicReadWriteObject(Double.valueOf("1.0"), "java.lang.Double:1.0\n");
    checkBasicReadWriteObject(Float.valueOf("1.0"), "java.lang.Float:1.0\n");
    checkBasicReadWriteObject(Integer.valueOf("1"), "java.lang.Integer:1\n");
    checkBasicReadWriteObject(Long.valueOf("1"), "java.lang.Long:1\n");
    checkBasicReadWriteObject(Short.valueOf("1"), "java.lang.Short:1\n");
    checkBasicReadWriteObject(BigDecimal.valueOf(500.5), "java.math.BigDecimal:500.5\n");
    checkBasicReadWriteObject(BigInteger.valueOf(500), "java.math.BigInteger:500\n");
    checkBasicReadWriteObject("1", "java.lang.String:1\n");
    checkBasicReadObject(Arrays.asList(new Object[] {"a", UtilMisc.toMap("b", Long.valueOf(1))}), "[\n \"a\",\n {\n  \"b\": 1\n }\n]\n");
    checkBasicReadWriteObject(MemoryType.HEAP, "java.lang.management.MemoryType:HEAP\n");
    checkBasicReadWriteObject(MemoryType.NON_HEAP, "java.lang.management.MemoryType:NON_HEAP\n");
    checkBasicReadWriteObject(UtilIO.UTF8, "java.nio.charset.Charset:UTF-8\n");
    checkBasicReadWriteObject(InetAddress.getByAddress("localhost", new byte[] {127, 0, 0, 1}), "java.net.InetAddress:localhost\n");
    //checkBasicReadWriteObject(Pattern.compile("^([a-z]{3}.*?):$"), "java.util.regex.Pattern:^([a-z]{3}.*?):$\n");
    checkBasicReadWriteObject(Time.valueOf("12:34:56"), "java.sql.Time:12:34:56\n");
    //checkBasicReadWriteObject(new Timestamp(1234567890), "java.sql.Timestamp:1234567890 00:00:00\n");
    //checkBasicReadWriteObject(new java.util.Date(1234567890), "java.util.Date:1234567890\n");
    checkBasicReadWriteObject(UUID.fromString("c3241927-9f77-43e1-be16-bd71d245ef64"), "java.util.UUID:c3241927-9f77-43e1-be16-bd71d245ef64\n");
    checkBasicReadWriteObject(TimeZone.getTimeZone("America/Chicago"), "java.util.TimeZone:America/Chicago\n");
    checkBasicReadWriteObject(new SimpleDateFormat("MM/dd/yyyy hh:mm a"), "java.text.SimpleDateFormat:MM/dd/yyyy hh:mm a\n");
    checkBasicReadWriteObject(new Locale("en", "us"), "java.util.Locale:en_US\n");
}
 
開發者ID:gildaslemoal,項目名稱:elpi,代碼行數:26,代碼來源:UtilIOTests.java


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