stack size

Discussion in 'C Programming' started by john blackburn, Oct 24, 2004.

  1. With gcc how do I increase the space available for the stack ?
     
    john blackburn, Oct 24, 2004
    #1
    1. Advertising

  2. john blackburn wrote:
    > With gcc how do I increase the space available for the stack ?

    This is a question about a specific implementation, not the C language.
    I recommend consulting your compiler docmentation. You should be able
    to type "info gcc" to get to it. I am pretty sure that there is an
    option for this.

    --
    Simon Richard Clarkstone
    s.r.cl*rkst*n*@durham.ac.uk / s*m*n_cl*rkst*n*@hotmail.com
     
    Simon Richard Clarkstone, Oct 24, 2004
    #2
    1. Advertising

  3. In article <417bc441$0$3035$>,
    john blackburn <> wrote:

    >With gcc how do I increase the space available for the stack ?


    This is probably an operating system limit, not a compiler one.
    If you're using unix, look at the "limit" or "ulimit" command.

    -- Richard
     
    Richard Tobin, Oct 24, 2004
    #3
  4. john blackburn

    Malcolm Guest

    "john blackburn" <> wrote
    >
    > With gcc how do I increase the space available for the stack ?
    >

    I don't know and it might not even be possible.
    Why are you gobbling up the stack so greedily? As a general rule, nothing
    bigger than 1K should go on the stack (use malloc() instead). Also, the code
    should be a roughly balanced tree of calls, so even a huge program won't be
    many routines deep. This leaves recursive functions. Do you need to pass
    every parameter to a recursive function, or can some be turned into globals?
    As a last resort, rewrite the code to eliminate the recursion.
     
    Malcolm, Oct 24, 2004
    #4
  5. john blackburn wrote:
    > With gcc how do I increase the space available for the stack ?



    Post gcc questions to a gnu.* newsgroup or to a newsgroup or mailing
    list for your particular implementation.
     
    Martin Ambuhl, Oct 24, 2004
    #5
  6. In article <clgpgq$riv$>,
    Malcolm <> wrote:

    >As a general rule, nothing
    >bigger than 1K should go on the stack (use malloc() instead).


    Why?

    You might as well say everything with stack scope should go on the
    stack.

    *If* you expect your program to be used in environments where the
    stack is small, don't put much on the stack. But the same applies to
    all limited resources.

    -- Richard
     
    Richard Tobin, Oct 25, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sunny
    Replies:
    5
    Views:
    2,150
    CBFalconer
    Aug 17, 2006
  2. Surinder Singh
    Replies:
    1
    Views:
    1,230
    Richard Bos
    Dec 20, 2007
  3. Casey Hawthorne
    Replies:
    3
    Views:
    1,119
    Flash Gordon
    Nov 1, 2009
  4. Debajit Adhikary
    Replies:
    36
    Views:
    2,358
    Andre Kaufmann
    Feb 10, 2011
  5. Sam Roberts
    Replies:
    1
    Views:
    233
    Yukihiro Matsumoto
    Feb 11, 2005
Loading...

Share This Page