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


Java MemoryPoolMXBean.getType方法代碼示例

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


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

示例1: isTenured

import java.lang.management.MemoryPoolMXBean; //導入方法依賴的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: poolSummaries

import java.lang.management.MemoryPoolMXBean; //導入方法依賴的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

示例3: findPool

import java.lang.management.MemoryPoolMXBean; //導入方法依賴的package包/類
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,代碼行數:15,代碼來源:MemoryMonitor.java

示例4: printUsage

import java.lang.management.MemoryPoolMXBean; //導入方法依賴的package包/類
/**
 * Выводит в stdout информацию о текущем состоянии различных разделов памяти.
 */
public static void printUsage(boolean heapOnly) {
    for(MemoryPoolMXBean mBean: ManagementFactory.getMemoryPoolMXBeans()) {
        if (!heapOnly || mBean.getType() == MemoryType.HEAP) {
            printMemUsage(mBean.getName(), mBean.getUsage());
        }
    }
}
 
開發者ID:vitaly-chibrikov,項目名稱:otus_java_2017_10,代碼行數:11,代碼來源:MemoryUtil.java


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