小秋的家

          home

            BlogJava :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
            1 Posts :: 91 Stories :: 17 Comments :: 0 Trackbacks
          public   class   T 
          {   
              public   static   void   main(String[]   args)   throws   Exception   
             
                  //   創(chuàng)建   1000   個   String   
                  String   strA[]   =   new   String[1000];   
                  long   start   =   0;   
                  long   end   =   0;  
                  //   先垃圾回收
                  System.gc();   
                  start   =   Runtime.getRuntime().freeMemory();   
                  for   (int   i   =   0;   i   <   1000;   i   ++)   
                  strA[i]   =   new   String();   
                   //   快要計(jì)算的時(shí),再清理一次   
                  System.gc();   
                  end   =   Runtime.getRuntime().freeMemory();   
                  System.out.println("一個String對象占內(nèi)存:"   +   (start   -   end)/1000.0);   
              } 
          }
              

                  
          posted on 2008-09-02 10:27 棋劍小秋 閱讀(277) 評論(0)  編輯  收藏 所屬分類: JAVA
          主站蜘蛛池模板: 黑河市| 南和县| 宁陵县| 新竹市| 汨罗市| 肃南| 鄂尔多斯市| 澄江县| 石棉县| 当涂县| 沿河| 镇平县| 娱乐| 黎平县| 乌兰浩特市| 敖汉旗| 遂川县| 扶绥县| 洪洞县| 乐安县| 南和县| 泗阳县| 固始县| 雅安市| 边坝县| 平利县| 广河县| 长顺县| 东莞市| 昌邑市| 伊春市| 延寿县| 巴里| 新泰市| 屏边| 治多县| 夏津县| 孙吴县| 黄龙县| 海盐县| 铜川市|