Java Memory measureMemoryBefore()

Here you can find the source of measureMemoryBefore()

Description

measure Memory Before

License

Open Source License

Declaration

public static void measureMemoryBefore() 

Method Source Code

//package com.java2s;

public class Main {
    public static final int MB = 1024 * 1024;

    public static void measureMemoryBefore() {
        measureMemory("Before");
    }//from  ww  w.j  av a 2  s .c  om

    public static void measureMemory(String phase) {
        long totalMemory = Runtime.getRuntime().totalMemory() / MB;
        long freeMemory = Runtime.getRuntime().freeMemory() / MB;
        long maxMemory = Runtime.getRuntime().maxMemory() / MB;

        //J-
        System.out.printf(
                "[%s]: total_memory=[%,d] (MB) \t free_memory=[%,d] (MB) \t max_memory=[%,d] (MB) \t used_memory=[%,d] (MB) \n",
                phase, totalMemory, freeMemory, maxMemory, totalMemory - freeMemory);
        //J+

    }
}

Related

  1. isMemoryAccess(final String value)
  2. isMemoryData(String metric)
  3. isMemorySufficient()
  4. logMemoryStats(String msg)
  5. makeVmMemoryDivisibleBy4(long memory)
  6. memory()
  7. memory()
  8. memory()
  9. memoryEqual(byte[] left, int leftOffset, byte[] right, int rightOffset, int length)