Java programmatic memory analysis


  public static void main(String[] args)
  {
    MemoryMXBean mbean = ManagementFactory.getMemoryMXBean();
    System.out.println(mbean.getHeapMemoryUsage());
    System.out.println("Avail " + (mbean.getHeapMemoryUsage().getMax() - mbean.getHeapMemoryUsage().getUsed()) / 1024 + "KB");
    
    List mbeans = ManagementFactory.getMemoryPoolMXBeans();
    for (MemoryPoolMXBean bean : mbeans)
    {
        String name = bean.getName();
        MemoryType type = bean.getType();
        MemoryUsage usage = bean.getUsage();
        MemoryUsage peak = bean.getPeakUsage();
        MemoryUsage coll = bean.getCollectionUsage();
        
        System.out.println(String.format("%s, type=%s, usage=%s, peak=%s, coll=%s", name, type, usage, peak, coll));
    }
  }

Comments

Popular posts from this blog

Sites, Newsletters, and Blogs

Oracle JDBC ReadTimeout QueryTimeout

Locks held on Oracle for hours after sessions abnormally terminated by node failure