This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Query
- From: Jack Lloyd <lloyd at acm dot jhu dot edu>
- To: "Bansal, Shashank" <Shashank dot Bansal at Dresdner-Bank dot com>
- Cc: "'gcc at gcc dot gnu dot org'" <gcc at gcc dot gnu dot org>
- Date: Thu, 6 Dec 2001 08:15:42 -0500 (EST)
- Subject: Re: Query
- Organization: JHU ACM/CS/CIRL
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