zoukankan      html  css  js  c++  java
  • 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 中也可以改变栈空间大小:

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

  • 相关阅读:
    链表栈
    C# TCP应用编程二 同步TCP应用编程
    C# TCP应用编程一 概述
    C# 网络流
    远程连接 出现身份验证错误,要求的函数不受支持(这可能是由于CredSSP加密Oracle修正)
    C#线程Thread类
    C# 通过Internet搜索网络资源
    正则表达式
    C#文件的读写
    微服务实战
  • 原文地址:https://www.cnblogs.com/Peter2014/p/7883259.html
Copyright © 2011-2022 走看看