Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to declare large array size?

Status
Not open for further replies.

kalaiarasi

Programmer
Feb 6, 2002
7
MY
Hi all,

Is it possible to declare large sized array?

double array[76800][76800];

I'm getting out of memory error.
My RAM is 64MB.

any other way of doing this?


Kalai.
 
yes there is another way, allocate the array dynamically at run time.

double **array;
int rows = 76800;
int cols = 76800;

// array of pointers to rows
array = new double *[rows];

// allocate each row to column number
for (int i = 0; i < rows; i++)
{
array = new double[cols];
}


// cleanup: delete row arrays
for (i = 0; i < rows; i++)
{
delete [] array;
}

// cleanup: delete array of row pointers and you're done
delete [] array;



 
Your array needs 47 GB memory - do You have so much on Your PC at all?
 
It all depends on what your application is doing. Is double precision needed? Is the matrix fully populated or is it sparse?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top