Re: Throwing bad_alloc when calling new on large class
- From: "Ben Voigt [C++ MVP]" <rbv@xxxxxxxxxxxxx>
- Date: Fri, 18 Jan 2008 06:45:18 -0600
"SteveZ" <SteveZ@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:1DABCB7F-CA1A-4970-9FEB-6E6F08C2BDC2@xxxxxxxxxxxxxxxx
"Brian Muth" wrote:
Both these statements are incorrect. 32-bit WinXP uses up to 3.5 GB of
physical memory regardless of the /3G switch. Each
application has either 2G or 3G of virtual address space depending on
the switch, and each application can have nearly unlimited
virtual memory using file mappings.
Thanks for the correction
You mentioned these are static arrays? They shouldn't add to the
per-instance object size at all.
I'm not convinced the OP actually used to static keyword. If so, this is
indeed a surprise, since the actual allocation is probably
quite small, and one wouldn't expect a bad_alloc exception. Perhaps the
OP can clarify.
Brian
Brian is correct. It was a poor choice of words on my part in the OP. I
should have said that they are fixed-size arrays, not static arrays. So
they
are allocated each time the class is created with new.
Since I am not using the complete physical address space and I should have
plenty of virutal memory (as indicated by Ben Voigt), I am still confused
as
to why the allocation of the class is failing. I should also mention that
this exception occurs on the first occurance of class allocation and is
consistent between program runs. Can the heap be this fragmented every
time
I run the program?
Your virtual address space is pretty fragmented, because dynamic libraries
are compiled to use random locations in the hope of preventing collisions.
(If there were a collision the loader would have to fixup every reference to
code, global variable, etc which adds a lot of overhead to initializing a
DLL).
Thanks.
-SteveZ
.
- References:
- Throwing bad_alloc when calling new on large class
- From: SteveZ
- Re: Throwing bad_alloc when calling new on large class
- From: Brian Muth
- Re: Throwing bad_alloc when calling new on large class
- From: Brian Muth
- Re: Throwing bad_alloc when calling new on large class
- From: Ben Voigt [C++ MVP]
- Re: Throwing bad_alloc when calling new on large class
- From: Brian Muth
- Throwing bad_alloc when calling new on large class
- Prev by Date: How "should" I remember and reuse form size and location?
- Next by Date: Wpf tooltip exist Direct3d memleak in native code in xp and vista os
- Previous by thread: Re: Throwing bad_alloc when calling new on large class
- Next by thread: Re: so, what is nnext then
- Index(es):
Relevant Pages
|