-
June 10th, 2009, 02:46 PM
#1
VS 2008, C++ std::bad_alloc at just 133 mb
I am running following code, trying to see how much max memory can i allocate
unsigned long* ptr;
for(unsigned long i=0; i<1000000000; i++) //1 billion
{
try
{
ptr = new unsigned long(0);
}
catch( bad_alloc &ba)
{
cout<<i;
}
}
I get bad_alloc exception at i=33401936, consider unsigned long takes 4 bytes, it is running out of memory at approx 133mb. However 32 bit address space should support up to 2GB. I have a 4GB ram so it should suffice and task manager says 2.5/4 GB is free.
I am using VS2008 on windows 7. Can anybody comment why is it failing at 133mb only.
Thanks,
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|