Discussions
Categories
Groups
Advertisement
Child Item
Home
Topics
Technology & Internet
Software & Web Development
Development
How to calculate min stack size
PDelux
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?
Find more posts tagged with
Quick Links
All Categories
Recent Posts
Activity
Unanswered
Groups
Best Of
Advertisement
Advertisement
Comments
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.
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.