Re: Is there a 1GB memory ceiling for vm_allocate?
Re: Is there a 1GB memory ceiling for vm_allocate?
- Subject: Re: Is there a 1GB memory ceiling for vm_allocate?
- From: "Sean McBride" <email@hidden>
- Date: Tue, 23 Jan 2007 17:05:08 -0500
- Organization: Rogue Research
On 2007-01-23 16:57, John Bullitt said:
>I'm trying to push_back() a bunch of elements into a vector. When
>push-back() tries to allocate more than 1GB, it fails.
>
>For example, the following little program will push_back() until it
>runs out of memory:
>
>#include <vector>
>int main (int argc, char * const argv[]) {
> std::vector<char> z;
> unsigned long int n;
> for (n=0;;n++) {
> z.push_back(0);
> }
>}
>
>I get an error like this: "malloc: *** vm_allocate(size=1073741824)
>failed (error code=3)" .
>
>Why is it running out of memory so soon? My G5 has 5 GB of RAM and
>175GB free disk space. I'm baffled.
>
>Is there maybe an XCode setting that I missed that can increase VM size?
The thing is that a 32bit process can only address (at the very most) 4
GB of virtual memory, regardless of the amount of physical memory you
have. You might want to read: <http://en.wikipedia.org/wiki/
Virtual_address_space>. So it's quite possible that trying to allocate
a whole 1 GB will fail.
One solution is to use a 64 bit process. But that will you limit you to
64bit CPU (G5 yes, G4 no). Also, on 10.4, you can't use Carbon or Cocoa
in a 64 bit app.
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden