linux查看修改線程預設棧空間大小(ulimit -s)

來源:互聯網
上載者:User

標籤:gets   type   get   mis   contain   not   conf   通過命令   limits   

1.linux查看修改線程預設棧空間大小 ulimit -s

a、通過命令 ulimit -s 查看linux的預設棧空間大小,預設情況下 為10240 即10M

b、通過命令 ulimit -s 設定大小值 臨時改變棧空間大小:ulimit -s 102400, 即修改為100M

c、可以在/etc/rc.local 內 加入 ulimit -s 102400 則可以開機就設定棧空間大小

d、在/etc/security/limits.conf 中也可以改變棧空間大小:

#<domain> <type> <item> <value>

* soft stack 102400

重新登入,執行ulimit -s 即可看到改為102400 即100M

 

2.為啥linux要限制使用者進程的棧記憶體大小。

Why does Linux have a default stack size soft limit of 8 MB?

The point is to protect the OS.

Programs that have a legitimate reason to need more stack are rare. On the other hand, programmer mistakes are common, and sometimes said mistakes lead to code that 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 memory. The soft limit on the stack size prevents this: the program will crash but the rest of the OS will be unaffected.

Note that as this is only a soft limit, you can actually modify it from within your program (see setrlimit(2): get/set resource limits) if you really need to.

linux查看修改線程預設棧空間大小(ulimit -s)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.