Linux view modify thread default stack space size (ulimit-s)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.