当前位置 : 主页 > 编程语言 > java >

内存错误检测器

来源:互联网 收集:自由互联 发布时间:2021-06-28
ArrayTest.java package myec_java_test;import java.util.ArrayList;import java.util.Scanner;public class ArrayTest {public static void main(String[] args) {System.out.println("vol ="+Integer.MAX_VALUE);Scanner in=new Scanner(System.in);System
ArrayTest.java
package myec_java_test;

import java.util.ArrayList;
import java.util.Scanner;

public class ArrayTest {
	public static void main(String[] args) {
		System.out.println("vol ="+Integer.MAX_VALUE);
		Scanner in=new Scanner(System.in);
		System.out.println("input item size");
		int cap=in.nextInt();
		in.close();
		int item[]=new int[cap];
		build_item(item);
		ArrayList
 
   testMain=new ArrayList
  
   (); build_testMain(testMain,item); int runCount=1; while(check_testMain(testMain,item)){ System.out.println(runCount+"..."); runCount++; } System.out.println("Error Found"); } static boolean check_testMain(ArrayList
   
     test,int item[]) { int vol=test.size(); int vol2=item.length; for(int i=0;i
    
      test,int item[]) { long maxMem=Runtime.getRuntime().maxMemory(); System.out.println("max Mem is:"+maxMem); long itemzise=item.length*Integer.BYTES; long testItemCount=maxMem/itemzise; System.out.println("total item in list is:"+testItemCount); testItemCount*=0.7; System.out.println("total item in list is:"+testItemCount); for(long i=0;i
    
   
  
 
上一篇:java 数组去重
下一篇:2017 12 8
网友评论