@Nonnull
        public static MemoryUsage createSnapshot()
        {
            final Runtime runtime = Runtime.getRuntime();

            final double freeMemory = (double)runtime.freeMemory()/(1024*1024);
            final double totalMemory = (double)runtime.totalMemory()/(1024*1024);
            final double maxMemory = (double)runtime.maxMemory()/(1024*1024);
            final double usedMemory = totalMemory - freeMemory;

            return new MemoryUsage(usedMemory, totalMemory, maxMemory);
        }
Creates a snapshot of the current memory usage.

@return memory usage statistics
xmppserver/src/main/java/org/jivesoftware/util/MemoryUsageMonitor.java