Query
Jack Lloyd
lloyd@acm.jhu.edu
Thu Dec 6 05:19:00 GMT 2001
On Thu, 6 Dec 2001, Bansal, Shashank wrote:
> Hi,
>
> I wished to create some large dimensional arrays in a program (6000x1000)
> and it fails to upload this memory (stack overflow). As soon as i reduce the
> dimension of arrays..it works perfectly.
Most likely you have a limit in place that limits the size of your stack.
Assuming you're running on a Unix system, try running the command `ulimit
-s`; that will tell you how much stack space you can allocate. You may be
able to raise this limit.
6000x1000x4 (array of ints), is about 22 megabytes. I suppose it is
possible that some machines and/or operating systems will not let you use
this much stack space ever.
> Could u help me out. I have tried this on different machines.
> Could you also tell if I could create virtual memory or somethign of that
> sort for the program.
The best solution is probably to use the C malloc function or the C++ new
operator to create the memory, or use C++'s vector<> type.
-Jack
More information about the Gcc
mailing list