统计java内存使用率代码

   public static boolean isMemEnough() {
        Runtime run = Runtime.getRuntime();
        long max = run.maxMemory() / 1024 / 1024;
        long used = (run.totalMemory() - run.freeMemory()) / 1024 / 1024;
        int percent = (int) ((double) used / (double) max * 100);
        String lpercent = ReadPropertiesUtil.get("mem_percent");
        return percent < Integer.parseInt(lpercent);
    }

你可能感兴趣的:(java,java,jvm,开发语言)