java.lang.OutOfMemoryError: Java heap space while

2020-07-11 07:46发布

I am trying to initialise an array of boolean type whose size is a 10 digit integer. It keeps on throwing OutOfMemoryException. I have increased the size of the heap space of eclipse to 1024 from 256. Is there anything that I am missing to do?

int size = 1000000000;
boolean[] primesList = new boolean[size];

7条回答
▲ chillily
2楼-- · 2020-07-11 08:14

When starting the JVM you need to pass a -Xmx parameter to set the maximum heap space as higher.

Also note that arrays have a maximum size of Integer.MAX_VALUE

查看更多
登录 后发表回答