use of java.lang.management.MemoryPoolMXBean in project geode by apache.
the class HeapMemoryMonitor method getAllMemoryPoolNames.
/**
* Returns the names of all available memory pools as a single string.
*/
private static String getAllMemoryPoolNames() {
StringBuilder builder = new StringBuilder("[");
for (MemoryPoolMXBean memoryPoolBean : ManagementFactory.getMemoryPoolMXBeans()) {
builder.append("(Name=").append(memoryPoolBean.getName()).append(";Type=").append(memoryPoolBean.getType()).append(";UsageThresholdSupported=").append(memoryPoolBean.isUsageThresholdSupported()).append("), ");
}
if (builder.length() > 1) {
builder.setLength(builder.length() - 2);
}
builder.append("]");
return builder.toString();
}
use of java.lang.management.MemoryPoolMXBean in project Lucee by lucee.
the class MacAddressWrap method 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;
}
use of java.lang.management.MemoryPoolMXBean in project checker-framework by typetools.
the class SourceChecker method printStats.
/**
* Print resource usage statistics
*/
protected void printStats() {
List<MemoryPoolMXBean> memoryPools = ManagementFactory.getMemoryPoolMXBeans();
for (MemoryPoolMXBean memoryPool : memoryPools) {
System.out.println("Memory pool " + memoryPool.getName() + " statistics");
System.out.println(" Pool type: " + memoryPool.getType());
System.out.println(" Peak usage: " + memoryPool.getPeakUsage());
}
}
use of java.lang.management.MemoryPoolMXBean in project Payara by payara.
the class MemoryReporter method getMemoryPoolReport.
private String getMemoryPoolReport() {
final StringBuilderNewLineAppender sb = new StringBuilderNewLineAppender(new StringBuilder());
final long millis = rmbean.getUptime();
final String uptime = sm.getString("uptime", JVMInformationCollector.millis2HoursMinutesSeconds(millis));
sb.append(uptime);
for (final MemoryPoolMXBean m : pools) {
final String n = m.getName();
sb.append(sm.getString("memory.pool.name", n));
MemoryUsage mu = m.getUsage();
sb.append(mu2String(mu));
}
return (sb.toString());
}
use of java.lang.management.MemoryPoolMXBean in project oap by oaplatform.
the class ObjectSizeCalculator method getEffectiveMemoryLayoutSpecification.
@VisibleForTesting
static MemoryLayoutSpecification getEffectiveMemoryLayoutSpecification() {
final String vmName = System.getProperty("java.vm.name");
if (vmName == null || !(vmName.startsWith("Java HotSpot(TM) ") || vmName.startsWith("OpenJDK") || vmName.startsWith("TwitterJDK"))) {
throw new UnsupportedOperationException("ObjectSizeCalculator only supported on HotSpot VM");
}
final String dataModel = System.getProperty("sun.arch.data.model");
if ("32".equals(dataModel)) {
// Running with 32-bit data model
return new MemoryLayoutSpecification() {
@Override
public int getArrayHeaderSize() {
return 12;
}
@Override
public int getObjectHeaderSize() {
return 8;
}
@Override
public int getObjectPadding() {
return 8;
}
@Override
public int getReferenceSize() {
return 4;
}
@Override
public int getSuperclassFieldPadding() {
return 4;
}
};
} else if (!"64".equals(dataModel)) {
throw new UnsupportedOperationException("Unrecognized value '" + dataModel + "' of sun.arch.data.model system property");
}
final String strVmVersion = System.getProperty("java.vm.version");
final int vmVersion = Integer.parseInt(strVmVersion.substring(0, strVmVersion.indexOf('.')));
if (vmVersion >= 17) {
long maxMemory = 0;
for (MemoryPoolMXBean mp : ManagementFactory.getMemoryPoolMXBeans()) {
maxMemory += mp.getUsage().getMax();
}
if (maxMemory < 30L * 1024 * 1024 * 1024) {
// for all memory pools (yes, including code cache).
return new MemoryLayoutSpecification() {
@Override
public int getArrayHeaderSize() {
return 16;
}
@Override
public int getObjectHeaderSize() {
return 12;
}
@Override
public int getObjectPadding() {
return 8;
}
@Override
public int getReferenceSize() {
return 4;
}
@Override
public int getSuperclassFieldPadding() {
return 4;
}
};
}
}
// In other cases, it's a 64-bit uncompressed OOPs object model
return new MemoryLayoutSpecification() {
@Override
public int getArrayHeaderSize() {
return 24;
}
@Override
public int getObjectHeaderSize() {
return 16;
}
@Override
public int getObjectPadding() {
return 8;
}
@Override
public int getReferenceSize() {
return 8;
}
@Override
public int getSuperclassFieldPadding() {
return 8;
}
};
}
Aggregations