private static MemoryPoolMXBean getTenuredGenPool() {
    for (MemoryPoolMXBean pool : ManagementFactory.getMemoryPoolMXBeans()) {
      final String vendor = System.getProperty("java.vendor");
      final boolean isTenured = isTenured(pool);
      if (!isTenured) {
        continue;
      }
      final boolean isCollectionUsageThresholdSupported = pool.isCollectionUsageThresholdSupported();
      if (isCollectionUsageThresholdSupported) {
        return pool;
      } else {
        final boolean isUsageThresholdSupported = pool.isUsageThresholdSupported();
        if (isUsageThresholdSupported) {
          return pool;
        } else {
          LOG.error("""
            {} vendor does not support isCollectionUsageThresholdSupported() and isUsageThresholdSupported()\
             for tenured memory pool '{}'.\
            """, vendor, pool.getName());
        }
      }
    }
    return null;
  }
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