* Maximum Allocatable Dynamic Memory
@ 2006-06-22 14:26 sonatabar bar
2006-06-22 18:35 ` Ian Lance Taylor
0 siblings, 1 reply; 2+ messages in thread
From: sonatabar bar @ 2006-06-22 14:26 UTC (permalink / raw)
To: gcc-help
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Maximum Allocatable Dynamic Memory
2006-06-22 14:26 Maximum Allocatable Dynamic Memory sonatabar bar
@ 2006-06-22 18:35 ` Ian Lance Taylor
0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 2006-06-22 18:35 UTC (permalink / raw)
To: sonatabar bar; +Cc: gcc-help
sonatabar bar <sonatabar@yahoo.com> writes:
> 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.
Wrong mailing list. This is not a gcc question. It is a kernel or a
library question.
I believe the answer is that the kernel permits you to allocate as
many pages as you like, but when you actually try to use them and it
looks for a place to put them, it will fail. I am not an expert,
though.
Ian
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-06-22 18:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-22 14:26 Maximum Allocatable Dynamic Memory sonatabar bar
2006-06-22 18:35 ` Ian Lance Taylor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).