mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-22 20:14:43 +02:00
8238665: Add JFR event for direct memory statistics
Reviewed-by: egahlin, alanb
This commit is contained in:
parent
1cc71b41de
commit
a62a0e5282
13 changed files with 276 additions and 27 deletions
|
@ -39,8 +39,9 @@ import java.security.AccessController;
|
|||
import java.security.PrivilegedActionException;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
|
||||
import jdk.internal.access.JavaNioAccess;
|
||||
import jdk.internal.access.SharedSecrets;
|
||||
import jdk.internal.misc.VM;
|
||||
import jdk.internal.misc.VM.BufferPool;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -52,6 +53,7 @@ import java.util.Collections;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* ManagementFactoryHelper provides static factory methods to create
|
||||
|
@ -337,16 +339,16 @@ public class ManagementFactoryHelper {
|
|||
static final PlatformLoggingMXBean MBEAN = getInstance();
|
||||
}
|
||||
|
||||
private static List<BufferPoolMXBean> bufferPools = null;
|
||||
public static synchronized List<BufferPoolMXBean> getBufferPoolMXBeans() {
|
||||
private static volatile List<BufferPoolMXBean> bufferPools;
|
||||
public static List<BufferPoolMXBean> getBufferPoolMXBeans() {
|
||||
if (bufferPools == null) {
|
||||
bufferPools = new ArrayList<>(2);
|
||||
bufferPools.add(createBufferPoolMXBean(SharedSecrets.getJavaNioAccess()
|
||||
.getDirectBufferPool()));
|
||||
bufferPools.add(createBufferPoolMXBean(sun.nio.ch.FileChannelImpl
|
||||
.getMappedBufferPool()));
|
||||
bufferPools.add(createBufferPoolMXBean(sun.nio.ch.FileChannelImpl
|
||||
.getSyncMappedBufferPool()));
|
||||
synchronized (ManagementFactoryHelper.class) {
|
||||
if (bufferPools == null) {
|
||||
bufferPools = VM.getBufferPools().stream()
|
||||
.map(ManagementFactoryHelper::createBufferPoolMXBean)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
}
|
||||
return bufferPools;
|
||||
}
|
||||
|
@ -357,7 +359,7 @@ public class ManagementFactoryHelper {
|
|||
* Creates management interface for the given buffer pool.
|
||||
*/
|
||||
private static BufferPoolMXBean
|
||||
createBufferPoolMXBean(final JavaNioAccess.BufferPool pool)
|
||||
createBufferPoolMXBean(final BufferPool pool)
|
||||
{
|
||||
return new BufferPoolMXBean() {
|
||||
private volatile ObjectName objname; // created lazily
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue