zoukankan      html  css  js  c++  java
  • RunTime类


    /*
     * 一个jvm对应一个Runtime类
     **/


    public class RuntimeDemo1 {

        public static void main(String args[])
        {
            //创建一个Runtime对象
            Runtime run=Runtime.getRuntime();
            try {
                //执行本地程序得到线程
                //Process pro=run.exec("freecell.exe");
                //Thread.sleep(2000);
                //关闭本地程序
                //pro.destroy();
                System.out.println("最大的可用内存:"+run.maxMemory());
                System.out.println("空闲的内存空间:"+run.freeMemory());
                System.out.println("总共内存空间:"+run.totalMemory());
                //消耗内存
                String i="";
                for(int j=0;j<Integer.MAX_VALUE;j++)
                {
                    i+=j;
                }
                System.out.println(i);
                //进行垃圾收集
                run.gc();
                //运行后的内存空间
                System.out.println("最大的可用内存:"+run.maxMemory());
                System.out.println("空闲的内存空间:"+run.freeMemory());
                System.out.println("总共内存空间:"+run.totalMemory());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

  • 相关阅读:
    AdaBoost算法学习
    梯度下降与随机梯度下降
    Logistic Regression学习
    PCA算法
    VS2013常见错误排查
    K临近算法
    遗传算法小结
    SLIC超像素(superpixel)算法
    openslide api函数概要
    线程钩子
  • 原文地址:https://www.cnblogs.com/jinzhengquan/p/1941556.html
Copyright © 2011-2022 走看看