public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: sonatabar bar <sonatabar@yahoo.com>
To: gcc-help@gcc.gnu.org
Subject: Maximum Allocatable Dynamic Memory
Date: Thu, 22 Jun 2006 14:26:00 -0000	[thread overview]
Message-ID: <20060622142626.85577.qmail@web36203.mail.mud.yahoo.com> (raw)

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 

             reply	other threads:[~2006-06-22 14:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-22 14:26 sonatabar bar [this message]
2006-06-22 18:35 ` Ian Lance Taylor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060622142626.85577.qmail@web36203.mail.mud.yahoo.com \
    --to=sonatabar@yahoo.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).