I am working on Ubuntu 11.04. How do I find out the maximum call stack size of a process and also the size of each frame of the stack?
It depends on your operating system. On Windows, the typical maximum size for a stack is 1MB, whereas it is 8MB on a typical modern Linux, although those values are adjustable in various ways.
On Linux/x86-32, the default stack size for a new thread is 2 megabytes. Under the NPTL threading implementation, if the RLIMIT_STACK soft resource limit at the time the program started has any value other than "unlimited", then it determines the default stack size of new threads.
In Visual Studio the default stack size is 1 MB i think, so with a recursion depth of 10,000 each stack frame can be at most ~100 bytes which should be sufficient for a DFS algorithm. Most compilers including Visual Studio let you specify the stack size.
You can query the maximum process and stack sizes using getrlimit . Stack frames don't have a fixed size; it depends on how much local data (i.e., local variables) each frame needs. To do this on the command-line, you can use ulimit.
A quick Google search should reveal some information on this subject.
> ulimit -a # shows the current stack size
You can query the maximum process and stack sizes using getrlimit
. Stack frames don't have a fixed size; it depends on how much local data (i.e., local variables) each frame needs.
To do this on the command-line, you can use ulimit.
If you want to read these values for a running process, I don't know of any tool that does this, but it's easy enough to query the /proc filesystem:
cat /proc/<pid>/limits
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With