Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I find the maximum stack size?

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?

like image 969
Bruce Avatar asked Sep 24 '11 00:09

Bruce


People also ask

Do stacks have a max size?

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.

What is the maximum stack size Linux?

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.

What is maximum call stack size in C?

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.

How do you calculate Max 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.


2 Answers

A quick Google search should reveal some information on this subject.

> ulimit -a         # shows the current stack size 
like image 188
fruchtose Avatar answered Sep 25 '22 07:09

fruchtose


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 
like image 20
Marcelo Cantos Avatar answered Sep 24 '22 07:09

Marcelo Cantos