Memory usage limits

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When I create an char array with more than approx 1,000,000 elements, I seem to run up against a stack overflow problem. I'm assuming that WinXP is only assigning a small amount of memory for this process. How do I get around this issue and increase the array size to one I'll need (approx 10,000,000 elements)?
 
Jeff Laidlaw said:
When I create an char array with more than approx 1,000,000 elements, I
seem to run up against a stack overflow problem. I'm assuming that WinXP is
only assigning a small amount of memory for this process. How do I get
around this issue and increase the array size to one I'll need (approx
10,000,000 elements)?

Allocate your array on the heap (with new or malloc) instead of the stack.
Consider using std::vector.

By default, your threads get only 1 or 2Mb of stack space. You can increase
the stack size using the linker /STACKSIZE: option, but you're better off
just getting such large arrays off the stack.

-cd
 
Back
Top