Maximum Allocatable Dynamic Memory

sonatabar bar sonatabar@yahoo.com
Thu Jun 22 14:26:00 GMT 2006


Hi,
I am trying to test what is the maximum allocatable
dynamic memory on a give machine. For my surprise I
see wonders happening, and I don't have an
explaination to it. I understand a bit that, it
doesn't have to do with compilers entirely, and hece
seeking explaination. 
 
this test fails allocating memory for index 68561
which means => allocated memory is (68561000000*8)
bytes =>X
=> X/1024/1024/1024 = 510.82 Gig ???
 
May be I am missing something, tried running it on a 2
& 4 Gig phyiscal memory machines, with a swap space of
8Gig.
 
I shall appreciate any feedback,
Thank you,
Sonata.
==========================================
 
#include <iostream>
// Million entries
#define X_DIM 1000000
using namespace std;
int main()
{
 cout<<"******** MEMORY ALLOCATION TEST:
********"<<endl;
 int size_d = sizeof(double);
 cout<<"Using Double: "<<size_d<<endl;
 int limit_reached = 0;
 double **dd_array;
 unsigned long int i = 0;
 dd_array = new double*[X_DIM];
 while(!limit_reached || i < X_DIM)
 {
        try{
                cerr<<"Trying allocation: "<<i<<endl;
                *(dd_array+i++) = new double[X_DIM];
                cerr<<"\t Allocated memory:
"<<std::scientific<<i*X_DIM<<endl;
        }
        catch(...){
                limit_reached = 1;
                cerr<<"\nUnable to allocate memory for
'Index': "<<i<<endl;
                return 0;
        }
 }
 cout<<"******* SUCCESSFUL MEMORY ALLOCATION
*******"<<endl;
 return(0);
}

Thank you,
Sonata.

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Gcc-help mailing list