code: public static List<MemoryInfo> getMemoryInfo() {
          Map<String, MemoryUsage> map = new TreeMap<>();
          List<MemoryPoolMXBean> memoryPoolMXBeanList = ManagementFactory.getMemoryPoolMXBeans();
          List<MemoryInfo> memoryInfoList = new ArrayList<>();
          for (MemoryPoolMXBean bean : memoryPoolMXBeanList) {
              String name = bean.getName();
              MemoryUsage memoryUsage = bean.getUsage();
              map.put(name, memoryUsage);
          }
  
          MemoryMXBean bean = ManagementFactory.getMemoryMXBean();
          // 堆内存总使用情况
          map.put("heapMemory", bean.getHeapMemoryUsage());
          // 非堆内存使用情况
          map.put("nonHeapMemory", bean.getNonHeapMemoryUsage());
  
          for (Map.Entry<String, MemoryUsage> entity : map.entrySet()) {
              String name = entity.getKey();
              MemoryUsage memoryUsage = entity.getValue();
              double init = (double) memoryUsage.getInit() / (1024 * 1024);
              double max = (double) memoryUsage.getMax() / (1024 * 1024);
              double used = (double) memoryUsage.getUsed() / (1024 * 1024);
              double committed = (double) memoryUsage.getCommitted() / (1024 * 1024);
              MemoryInfo info = new MemoryInfo(name, init, used, committed, max);
              memoryInfoList.add(info);
          }
          return memoryInfoList;
      }
docs: 获取各个内存区的使用情况
  
  @return 各个内存区的使用情况