How do I find the maximum stack size?

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

The following call to ulimit returns the maximum stack size in kibibytes (210 = 1024 bytes):

ulimit -s

You can use getrlimit to see the stack size and setrlimit to change it.

There's an example in the Increase stack size in Linux with setrlimit post.