Creating "could not reserve enough space for object heap" error

Is there a utility (for Windows) that uses up memory so I can create a JVM "could not reserve enough space for object heap" error?

I want to use up this memory in a process outside of the JVM.


Just use the -Xms flag

java -Xms3g org.foo.Main

The above will try to create an initial heap size of 3 GB, just adjust the number so it is larger than the total memory of your system (physical & virtual)


I think you can try with this one:

String s = "b";
for (int i = 0; i < 1000 000; i++) {
  s+="b";
}

Because new string will be allocated everytime the line s+="b" is run, it should run out of java heap.


List<Object> leak = new ArrayList<Object>();
while(true) {
    leak.add(new Object());
}
链接地址: http://www.djcxy.com/p/82954.html

上一篇: 问题,而开始Grails应用程序

下一篇: 创建“无法为对象堆预留足够的空间”错误