code: public static String getMemoryUsageStatsAsString(MemoryMXBean memoryMXBean) {
  		MemoryUsage heap = memoryMXBean.getHeapMemoryUsage();
  		MemoryUsage nonHeap = memoryMXBean.getNonHeapMemoryUsage();
  
  		long heapUsed = heap.getUsed() >> 20;
  		long heapCommitted = heap.getCommitted() >> 20;
  		long heapMax = heap.getMax() >> 20;
  
  		long nonHeapUsed = nonHeap.getUsed() >> 20;
  		long nonHeapCommitted = nonHeap.getCommitted() >> 20;
  		long nonHeapMax = nonHeap.getMax() >> 20;
  
  		return String.format("Memory usage stats: [HEAP: %d/%d/%d MB, " +
  				"NON HEAP: %d/%d/%d MB (used/committed/max)]",
  				heapUsed, heapCommitted, heapMax, nonHeapUsed, nonHeapCommitted, nonHeapMax);
  	}
docs: Gets the memory footprint of the JVM in a string representation.
  
  @return A string describing how much heap memory and direct memory are allocated and used.