1.linux view modify thread default stack space size ulimit-s
A, by the command ulimit-s view the default stack space size of Linux, by default 10240 is 10M
b, by the command ulimit-s set size value temporarily change the stack space size: Ulimit-s 102400, that is, modified to 100M
C, can be added in/etc/rc.local ulimit-s 102400 can be switched on to set the size of the stack space
D, in/etc/security/limits.conf can also change the size of the stack space:
#<domain> <type> <item> <value>
* Soft Stack 102400
Re-login, execute ulimit-s can see Change to 102400 is 100M
2. Why Linux restricts the stack memory size of user processes.
Why does Linux has a default stack size soft limit of 8 MB?
The point was to protect the OS.
Programs that has a legitimate reason to need more stack is rare. On the other hand, programmer mistakes is common, and sometimes said mistakes leads to code this gets stuck in an infinite Loop. And if that infinite loop happens to contain a recursive function call, the stack would quickly eat all the available memo Ry. The soft limit on the stack size prevents this:the program would crash but the rest of the OS would be unaffected.
Note that as this is only a soft limit, you can actually modify it from the within your program (see Setrlimit (2): Get/set res Ource limits) If you really need to.
Linux view modify thread default stack space size (ulimit-s)