Out Of Memory help from sun's siteを使用しました。それはOut Of Memoryをシミュレートする方法:要求された配列サイズがVM制限を超えています
Out Of Memory : Requested array size exceeds VM limit
This indicates that the application attempted to allocate an array that is larger than the heap size. For example, if an application tries to allocate an array of 512MB but the maximum heap size is 256MB, then this error will be thrown. In most cases the problem is likely to be either that the heap size is too small or that a bug results in the application attempting to create an array whose size is calculated to be incorrectly huge.
として引用されている場合、私は
javac *.java;java -Xmx256m JavaTest
で私のマシンで
import java.util.ArrayList;
import java.util.List;
public class JavaTest {
public static void main(String[] args){
long[] ll = new long[64*1024*1024];
}
}
ことによって、これをシミュレートしようとしましたが、上記の行は
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at JavaTest.main(JavaTest.java:7)
何を生産しています私は行方不明ですか?
更新: 私のJavaのバージョンが
$java -version java version "1.6.0_15" Java(TM) SE Runtime Environment (build 1.6.0_15-b03) Java HotSpot(TM) Server VM (build 14.1-b02, mixed mode)
ありがとうございました。これも私のために働いています。しかし、私のコードはなぜ早く働かなかったのですか? – DKSRathore
したがって、私のシステムは、1024 * 1024 * 1024-2からInteger.MAX_VALUEの範囲でこの例外を生成しています – DKSRathore
@Adrian、VMの制限はどのように知っていますか? – DKSRathore