diff --git a/common/src/main/java/io/netty/util/internal/PlatformDependent.java b/common/src/main/java/io/netty/util/internal/PlatformDependent.java index 8696996fcb..7614ff9bd9 100644 --- a/common/src/main/java/io/netty/util/internal/PlatformDependent.java +++ b/common/src/main/java/io/netty/util/internal/PlatformDependent.java @@ -288,6 +288,16 @@ public final class PlatformDependent { return DIRECT_MEMORY_LIMIT; } + /** + * Returns the current memory reserved for direct buffer allocation. + * This method returns -1 in case that a value is not available. + * + * @see #maxDirectMemory() + */ + public static long usedDirectMemory() { + return DIRECT_MEMORY_COUNTER != null ? DIRECT_MEMORY_COUNTER.get() : -1; + } + /** * Returns the temporary directory. */