Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

How to calculate min stack size

  • 06-02-2006 02:13PM
    #1
    Closed Accounts Posts: 296 ✭✭


    Hi
    I'm looking for some ways to determine the min stack size i need for my C program. What is the easiest way to calculate how big the stack will grow during runtime?


Comments

  • Registered Users, Registered Users 2 Posts: 441 ✭✭robfitz


    On linux you can use ulimit to set the maximum stack size for a subprocess, the -s value is the size in kilobytes.
    $ ulimit -s 16
    $ java
    # Crash

    You can repeat the commands increasing the -s value until you program doesn't crash anymore.

    Unless your developing for an embedded system you shouldn't have to worrry about the stack size. The problem is mostly likely with your code, you should change your code not to declare large structures on the stack, or not use recursion.


  • Closed Accounts Posts: 296 ✭✭PDelux


    Thanks robfitz, that's a good idea, I can try that.

    It is actually an embedded system I'm working on(USB device) so I need to squeeze every last byte of RAM out of it.


Advertisement