Java Memory memory()

Here you can find the source of memory()

Description

memory

License

Open Source License

Declaration

public static String memory() 

Method Source Code

//package com.java2s;
/**/*from w  w  w . j  av a2 s  .  c om*/
 * Copyright (C) 2009 G?nter Ladwig (gla at aifb.uni-karlsruhe.de)
 * 
 * This file is part of the graphindex project.
 *
 * graphindex is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License, version 2
 * as published by the Free Software Foundation.
 * 
 * graphindex is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with graphindex.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    public static String memory() {
        Runtime r = Runtime.getRuntime();
        long max = r.maxMemory() / 1000;
        return "memory (used/free/max): " + (max - freeMemory()) / 1000 + "/" + freeMemory() / 1000 + "/"
                + r.maxMemory() / 1000000;
    }

    public static long freeMemory() {
        Runtime r = Runtime.getRuntime();
        return (r.freeMemory() + (r.maxMemory() - r.totalMemory())) / 1000;
    }
}

Related

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