code: public static long maxMemory() {
          long memory = 0;
          for (MemoryPoolMXBean mp : ManagementFactory.getMemoryPoolMXBeans()) {
              memory += mp.getUsage().getMax();
          }
          return memory;
      }
docs: Represents the maximum amount of memory (in bytes) that can be used for memory management.
  Its value may be undefined. The maximum amount of memory may change over time if defined.
  The amount of used and committed memory will always be less than or equal to max if max is defined.
  
  @return memory