private static boolean isTenured(MemoryPoolMXBean memoryPoolMXBean) {
    if (memoryPoolMXBean.getType() != MemoryType.HEAP) {
      return false;
    }

    String name = memoryPoolMXBean.getName();
    return name.equals("CMS Old Gen") // CMS
      || name.equals("PS Old Gen") // Parallel GC
      || name.equals("G1 Old Gen") // G1GC
      // other vendors like IBM, Azul etc. use different names
      || name.equals("Old Space")
      || name.equals("Tenured Gen")
      || name.equals("Java heap")
      || name.equals("GenPauseless Old Gen");
  }
Class that monitors memory usage and notifies the listeners when a certain of threshold of memory is used
after GC (collection usage).
common/src/java/org/apache/hadoop/hive/common/HeapMemoryMonitor.java