[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Max size of data in C++ prog?



On Sat, Dec 18, 2004 at 07:10:22PM -0500, Marc Shapiro wrote:
} Is there a maximum size to the data segment in a C++ program?  More 
} specifically, I am trying to write a program with a very large array. 
} The program compiles OK (since C/C++ do no bounds checking on arrays), 
} but segfaults when I try to run it.  The limit seems to be at just under 
} 8MB.  Is there a way to allocate more space for data?

If you are allocating the array on the stack, you may be running into a
limit on the size of the stack. I recommend either allocating it
dynamically (i.e. from the heap with new) or statically/globally (a static
member of a class or a global variable).

} Marc Shapiro
} mshapiro_42@yahoo.com
--Greg



Reply to: