8246259: JFR: Fetch VM memory pools without using streams
Reviewed-by: mgronlun
This commit is contained in:
parent
5e5880d4f1
commit
567692e4ae
@ -26,31 +26,36 @@
|
||||
package jdk.jfr.events;
|
||||
|
||||
import jdk.internal.misc.VM.BufferPool;
|
||||
|
||||
import jdk.internal.misc.VM;
|
||||
import jdk.jfr.*;
|
||||
import jdk.jfr.internal.Type;
|
||||
|
||||
@Category({ "Java Application", "Statistics" })
|
||||
public abstract class AbstractBufferStatisticsEvent extends AbstractJDKEvent {
|
||||
|
||||
AbstractBufferStatisticsEvent() {
|
||||
BufferPool bufferPool = getBufferPool();
|
||||
|
||||
protected AbstractBufferStatisticsEvent(BufferPool bufferPool) {
|
||||
count = bufferPool.getCount();
|
||||
totalCapacity = bufferPool.getTotalCapacity();
|
||||
memoryUsed = bufferPool.getMemoryUsed();
|
||||
}
|
||||
|
||||
@Label("Count")
|
||||
public long count;
|
||||
final long count;
|
||||
|
||||
@Label("Total Capacity")
|
||||
@DataAmount
|
||||
public long totalCapacity;
|
||||
final long totalCapacity;
|
||||
|
||||
@Label("Memory Used")
|
||||
@DataAmount
|
||||
public long memoryUsed;
|
||||
final long memoryUsed;
|
||||
|
||||
abstract BufferPool getBufferPool();
|
||||
static BufferPool findPoolByName(String name) {
|
||||
for (BufferPool pool : VM.getBufferPools()) {
|
||||
if (pool.getName().equals(name)) {
|
||||
return pool;
|
||||
}
|
||||
}
|
||||
throw new InternalError("No buffer pool with name " + name);
|
||||
}
|
||||
}
|
||||
|
@ -36,20 +36,15 @@ import jdk.jfr.internal.Type;
|
||||
@Description("Statistics of direct buffer")
|
||||
public final class DirectBufferStatisticsEvent extends AbstractBufferStatisticsEvent {
|
||||
|
||||
private static final BufferPool DIRECT_BUFFER_POOL = VM.getBufferPools().stream()
|
||||
.filter(p -> "direct".equals(p.getName()))
|
||||
.findFirst().get();
|
||||
private static final BufferPool DIRECT_BUFFER_POOL = findPoolByName("direct");
|
||||
|
||||
public DirectBufferStatisticsEvent() {
|
||||
super(DIRECT_BUFFER_POOL);
|
||||
this.maxCapacity = VM.maxDirectMemory();
|
||||
}
|
||||
|
||||
@Label("Maximum Capacity")
|
||||
@Description("Maximum direct buffer capacity the process can use")
|
||||
@DataAmount
|
||||
public long maxCapacity;
|
||||
|
||||
BufferPool getBufferPool() {
|
||||
return DIRECT_BUFFER_POOL;
|
||||
}
|
||||
final long maxCapacity;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user