本文整理匯總了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));
}
示例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();
}
示例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);
}
示例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());
}
}
}