Skip to main content

allocating a big array

3 replies [Last post]
m68_1
Offline
Joined: 2006-10-02

Hi,

I am trying to allocate some large arrays to store data,

double [][] x;
x = new double [700000][6];

compiled ok, but it gives me a runtime error:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

any idea how to allocate arrays with millions of rows?

thanks a lot in advance

mike

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
m68_1
Offline
Joined: 2006-10-02

Hi

Sorry to come back with more questions. Here is the situation:

the code: double [][] x = new double [25000000][6];
the machine: win server 2003 machine with 4GB ram
java version: 1.6.0 beta
command: java -Xmx2048M MyClass

error: error occured during initialization of VM
could not reserve enough space for object heap
could not create the java virtual machine

any insight?

realityfaker
Offline
Joined: 2006-07-21

your should add -Xmx1024M parameter after word java in your command line:

such as java -Xmx1024M MyClass

m68_1
Offline
Joined: 2006-10-02

many thanks, it works!