How do I find the maximum stack size?

2019-01-13 03:24发布

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?

5条回答
Rolldiameter
2楼-- · 2019-01-13 03:57

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.

查看更多
闹够了就滚
3楼-- · 2019-01-13 04:01

getrlimit() and setrlimit() are not Linux commands. They are system calls.

So in order to get the result of them, you need something like a bash script or any other executable script that returns the result of the system call.

查看更多
太酷不给撩
4楼-- · 2019-01-13 04:09

Maximum stack size in kilobytes:

ulimit -s
查看更多
聊天终结者
5楼-- · 2019-01-13 04:13

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
查看更多
放荡不羁爱自由
6楼-- · 2019-01-13 04:17

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

> ulimit -a         # shows the current stack size
查看更多
登录 后发表回答