linux 改变空间大小,linux查看修改线程默认栈空间大小(ulimit -s)

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 中也可以改变栈空间大小:

#

* 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.

原文:http://www.cnblogs.com/Peter2014/p/7883259.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值