This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Query
- From: "Tim Prince" <tprince at computer dot org>
- To: "Jack Lloyd" <lloyd at acm dot jhu dot edu>,"Bansal, Shashank" <Shashank dot Bansal at Dresdner-Bank dot com>
- Cc: <gcc at gcc dot gnu dot org>
- Date: Thu, 6 Dec 2001 07:23:50 -0800
- Subject: Re: Query
- References: <Pine.LNX.4.30.0112060810550.27655-100000@sol.galaxy.acm.jhu.edu>
----- Original Message -----
From: "Jack Lloyd" <lloyd@acm.jhu.edu>
To: "Bansal, Shashank" <Shashank.Bansal@Dresdner-Bank.com>
Cc: <gcc@gcc.gnu.org>
Sent: Thursday, December 06, 2001 5:15 AM
Subject: Re: Query
> 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
>
Current stock linux distributions have a fixed 8MB stack limit. Not long
ago it was 1MB. A scheme to adjust this, including ulimit, as Jack
describes, and a re-configuration parameter, are sorely needed. In
addition, compilers need a scheme such as the one planned for g95, where
objects above a certain size (threshold set by a compiler option), are
automatically put on the heap. Top quality Unix compilers have such a
scheme. The current situation, where code has to be modified with explicit
use of malloc() in order to port to linux from Unix or Windows, is
unsatisfactory.