public static long getDirectMemoryUsage() {
    if (BEAN_SERVER == null || NIO_DIRECT_POOL == null || !HAS_MEMORY_USED_ATTRIBUTE) return 0;
    try {
      Long value = (Long) BEAN_SERVER.getAttribute(NIO_DIRECT_POOL, MEMORY_USED);
      return value == null ? 0 : value;
    } catch (JMException e) {
      // should print further diagnostic information?
      return 0;
    }
  }
Returns the current amount of direct memory used.
hbase-server/src/main/java/org/apache/hadoop/hbase/util/DirectMemoryUtils.java