How to measure the stack size of a process?

后端 未结 2 464
离开以前
离开以前 2021-01-12 02:44

How do I find the stack size of a process ? /proc/5848/status gives me VmStk but this doesnt change

No matter how much ever while loop and recursion I do in my test

2条回答
  •  借酒劲吻你
    2021-01-12 03:03

    Maybe you just want to get the address map of some process. For process 1234, read sequentially the /proc/1234/maps pseudo-file. For your own process, read /proc/self/maps

    Try

     cat /proc/self/maps
    

    to get a feeling of it (the above command displays the address map of the cat process executing it).

    Read proc(5) man page for details.

    You might also be interested by process limits, e.g. getrlimit(2) and related syscalls.

    I am not sure that stack size has some precise sense, notably for multi-threaded processes.

    Maybe you are interested in mmap(2)-ed segments with MAP_GROWSDOWN.

提交回复
热议问题