use of java.lang.management.MemoryUsage in project jdk8u_jdk by JetBrains.
the class MemoryPoolImpl method setCollectionUsageThreshold.
public void setCollectionUsageThreshold(long newThreshold) {
if (!isCollectionUsageThresholdSupported()) {
throw new UnsupportedOperationException("CollectionUsage threshold is not supported");
}
Util.checkControlAccess();
MemoryUsage usage = getUsage0();
if (newThreshold < 0) {
throw new IllegalArgumentException("Invalid threshold: " + newThreshold);
}
if (usage.getMax() != -1 && newThreshold > usage.getMax()) {
throw new IllegalArgumentException("Invalid threshold: " + newThreshold + " > max (" + usage.getMax() + ").");
}
synchronized (this) {
if (!gcSensorRegistered) {
// pass the sensor to VM to begin monitoring
gcSensorRegistered = true;
setPoolCollectionSensor(gcSensor);
}
setCollectionThreshold0(collectionThreshold, newThreshold);
this.collectionThreshold = newThreshold;
}
}
use of java.lang.management.MemoryUsage in project jdk8u_jdk by JetBrains.
the class JvmMemPoolEntryImpl method getCollectMemoryUsage.
MemoryUsage getCollectMemoryUsage() {
try {
final Map<Object, Object> m = JvmContextFactory.getUserData();
if (m != null) {
final MemoryUsage cached = (MemoryUsage) m.get(entryCollectMemoryTag);
if (cached != null) {
if (log.isDebugOn())
log.debug("getCollectMemoryUsage", entryCollectMemoryTag + " found in cache.");
return cached;
}
MemoryUsage u = pool.getCollectionUsage();
if (u == null)
u = ZEROS;
m.put(entryCollectMemoryTag, u);
return u;
}
// Should never come here.
// Log error!
log.trace("getCollectMemoryUsage", "ERROR: should never come here!");
return ZEROS;
} catch (RuntimeException x) {
log.trace("getPeakMemoryUsage", "Failed to get MemoryUsage: " + x);
log.debug("getPeakMemoryUsage", x);
throw x;
}
}
use of java.lang.management.MemoryUsage in project jdk8u_jdk by JetBrains.
the class JvmMemoryImpl method getHeapMemoryUsage.
MemoryUsage getHeapMemoryUsage() {
try {
final Map<Object, Object> m = JvmContextFactory.getUserData();
if (m != null) {
final MemoryUsage cached = (MemoryUsage) m.get(heapMemoryTag);
if (cached != null) {
log.debug("getHeapMemoryUsage", "jvmMemory.getHeapMemoryUsage found in cache.");
return cached;
}
final MemoryUsage u = getMemoryUsage(MemoryType.HEAP);
// getHeapMemoryUsage() never returns null.
//
// if (u == null) u=MemoryUsage.INVALID;
m.put(heapMemoryTag, u);
return u;
}
// Should never come here.
// Log error!
log.trace("getHeapMemoryUsage", "ERROR: should never come here!");
return getMemoryUsage(MemoryType.HEAP);
} catch (RuntimeException x) {
log.trace("getHeapMemoryUsage", "Failed to get HeapMemoryUsage: " + x);
log.debug("getHeapMemoryUsage", x);
throw x;
}
}
use of java.lang.management.MemoryUsage in project jdk8u_jdk by JetBrains.
the class JvmMemoryImpl method getNonHeapMemoryUsage.
MemoryUsage getNonHeapMemoryUsage() {
try {
final Map<Object, Object> m = JvmContextFactory.getUserData();
if (m != null) {
final MemoryUsage cached = (MemoryUsage) m.get(nonHeapMemoryTag);
if (cached != null) {
log.debug("getNonHeapMemoryUsage", "jvmMemory.getNonHeapMemoryUsage found in cache.");
return cached;
}
final MemoryUsage u = getMemoryUsage(MemoryType.NON_HEAP);
// getNonHeapMemoryUsage() never returns null.
//
// if (u == null) u=MemoryUsage.INVALID;
m.put(nonHeapMemoryTag, u);
return u;
}
// Should never come here.
// Log error!
log.trace("getNonHeapMemoryUsage", "ERROR: should never come here!");
return getMemoryUsage(MemoryType.NON_HEAP);
} catch (RuntimeException x) {
log.trace("getNonHeapMemoryUsage", "Failed to get NonHeapMemoryUsage: " + x);
log.debug("getNonHeapMemoryUsage", x);
throw x;
}
}
use of java.lang.management.MemoryUsage in project jdk8u_jdk by JetBrains.
the class JvmMemPoolEntryImpl method getPeakMemoryUsage.
MemoryUsage getPeakMemoryUsage() {
try {
final Map<Object, Object> m = JvmContextFactory.getUserData();
if (m != null) {
final MemoryUsage cached = (MemoryUsage) m.get(entryPeakMemoryTag);
if (cached != null) {
if (log.isDebugOn())
log.debug("getPeakMemoryUsage", entryPeakMemoryTag + " found in cache.");
return cached;
}
MemoryUsage u = pool.getPeakUsage();
if (u == null)
u = ZEROS;
m.put(entryPeakMemoryTag, u);
return u;
}
// Should never come here.
// Log error!
log.trace("getPeakMemoryUsage", "ERROR: should never come here!");
return ZEROS;
} catch (RuntimeException x) {
log.trace("getPeakMemoryUsage", "Failed to get MemoryUsage: " + x);
log.debug("getPeakMemoryUsage", x);
throw x;
}
}
Aggregations