< prev index next >
src/java.base/share/classes/jdk/internal/misc/VM.java
Print this page
rev 58228 : 8238665: Add JFR event for direct memory statistics
*** 25,38 ****
--- 25,44 ----
package jdk.internal.misc;
import static java.lang.Thread.State.*;
+ import java.util.ArrayList;
import java.util.Collections;
+ import java.util.List;
import java.util.Map;
import java.util.Properties;
+ import jdk.internal.access.SharedSecrets;
+
+ import sun.nio.ch.FileChannelImpl;
+
public class VM {
// the init level when the VM is fully initialized
private static final int JAVA_LANG_SYSTEM_INITED = 1;
private static final int MODULE_SYSTEM_INITED = 2;
*** 412,417 ****
--- 418,453 ----
* Those static fields remain as uninitialized if there is no mapped CDS
* java heap data or there is any error during initialization of the
* object class in the archived graph.
*/
public static native void initializeFromArchive(Class<?> c);
+
+ /**
+ * Provides access to information on buffer usage.
+ */
+ public interface BufferPool {
+ String getName();
+ long getCount();
+ long getTotalCapacity();
+ long getMemoryUsed();
+ }
+
+ private static class BufferPoolsHolder {
+ static final List<BufferPool> BUFFER_POOLS;
+
+ static {
+ ArrayList<BufferPool> bufferPools = new ArrayList<>(3);
+ bufferPools.add(SharedSecrets.getJavaNioAccess().getDirectBufferPool());
+ bufferPools.add(FileChannelImpl.getMappedBufferPool());
+ bufferPools.add(FileChannelImpl.getSyncMappedBufferPool());
+
+ BUFFER_POOLS = Collections.unmodifiableList(bufferPools);
+ }
+ }
+
+ /**
+ * @return the list of buffer pools.
+ */
+ public static List<BufferPool> getBufferPools() {
+ return BufferPoolsHolder.BUFFER_POOLS;
+ }
}
< prev index next >