本文整理汇总了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();
}
示例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");
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例8: getType
public MemoryType getType() {
if (isHeap) {
return MemoryType.HEAP;
} else {
return MemoryType.NON_HEAP;
}
}
示例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());*/
}
示例10: isOffheap
boolean isOffheap() {
return this.memType == MemoryType.NON_HEAP;
}