private void getMemoryUsage(MetricsRecordBuilder rb) {
    MemoryUsage memNonHeap = memoryMXBean.getNonHeapMemoryUsage();
    MemoryUsage memHeap = memoryMXBean.getHeapMemoryUsage();
    Runtime runtime = Runtime.getRuntime();
    rb.addGauge(MemNonHeapUsedM, memNonHeap.getUsed() / M)
        .addGauge(MemNonHeapCommittedM, memNonHeap.getCommitted() / M)
        .addGauge(MemNonHeapMaxM, memNonHeap.getMax() / M)
        .addGauge(MemHeapUsedM, memHeap.getUsed() / M)
        .addGauge(MemHeapCommittedM, memHeap.getCommitted() / M)
        .addGauge(MemHeapMaxM, memHeap.getMax() / M)
        .addGauge(MemMaxM, runtime.maxMemory() / M);
  }
JVM and logging related metrics. Ported from Hadoop JvmMetrics.
Mostly used by various servers as a part of the metrics they export.
common/src/java/org/apache/hadoop/hive/common/JvmMetrics.java