JAVA内存溢出异常解决方案
来源:优易学  2011-9-15 11:11:19   【优易学:中国教育考试门户网】   资料下载   IT书店

  public static void changeJVMArguments() {
  long startTime = System.currentTimeMillis();
  System.out.println("Start : " + startTime);
  List list = new ArrayList(0);
  for (int i = 0; i < 5000000; i++) {
  list.add(new BigInteger("1000000"));
  }
  long endTime = System.currentTimeMillis();
  System.out.println("End.. : " + endTime + " Cost : "
  + (endTime - startTime));
  }
  /**
  * Release Object Immediate
  * 立即 释放无用的对象
  *
  *
  * Release Object
  *
  *
  * //First Release Object
  * BigInteger temp1 = null;
  * for (int i = 0; i < 1200000; i++) {
  * temp1 = array1[i];
  * temp1 = null;
  * array1[i] = null;
  * }
  * array1 = null;
  * ...
  * //Second Release Object
  * temp1 = null;
  * for (int i = 0; i < 1200000; i++) {
  * temp1 = array2[i];
  * temp1 = null;
  * array2[i] = null;
  * }
  * array2 = null;
  *
  *
  */

上一页  [1] [2] [3] [4] [5] 下一页

责任编辑:小草

文章搜索:
 相关文章
热点资讯
资讯快报
热门课程培训