
{"id":2616,"date":"2023-01-16T16:03:22","date_gmt":"2023-01-16T08:03:22","guid":{"rendered":"http:\/\/dba.qishuo.xin\/?p=2616"},"modified":"2023-01-18T16:50:19","modified_gmt":"2023-01-18T08:50:19","slug":"%e8%a7%a3%e5%86%b3java-lang-outofmemoryerror-unable-to-create-new-native-thread","status":"publish","type":"post","link":"http:\/\/dba.qishuo.xin\/?p=2616","title":{"rendered":"\u89e3\u51b3java.lang.OutOfMemoryError: unable to create new native thread"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_76 ez-toc-wrap-right counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<label for=\"ez-toc-cssicon-toggle-item-6a020b9f96e0c\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a020b9f96e0c\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"http:\/\/dba.qishuo.xin\/?p=2616\/#1_%E6%95%85%E9%9A%9C%E7%8E%B0%E8%B1%A1%E4%B8%8E%E5%88%86%E6%9E%90\" >1. \u6545\u969c\u73b0\u8c61\u4e0e\u5206\u6790<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"http:\/\/dba.qishuo.xin\/?p=2616\/#11_%E6%95%85%E9%9A%9C%E5%8F%91%E7%94%9F%E7%9A%84%E6%97%B6%E9%97%B4%E4%B8%8E%E7%8E%B0%E8%B1%A1SYMPTOMS\" >1.1. \u6545\u969c\u53d1\u751f\u7684\u65f6\u95f4\u4e0e\u73b0\u8c61(SYMPTOMS)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"http:\/\/dba.qishuo.xin\/?p=2616\/#12_%E5%88%86%E6%9E%90%E8%BF%87%E7%A8%8BANALYSIS\" >1.2. \u5206\u6790\u8fc7\u7a0b(ANALYSIS)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"http:\/\/dba.qishuo.xin\/?p=2616\/#13_%E6%A0%B9%E6%9C%AC%E5%8E%9F%E5%9B%A0CAUSE\" >1.3. \u6839\u672c\u539f\u56e0(CAUSE)<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"http:\/\/dba.qishuo.xin\/?p=2616\/#2_%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88%E4%B8%8E%E9%81%97%E7%95%99%E9%97%AE%E9%A2%98\" >2. \u89e3\u51b3\u65b9\u6848\u4e0e\u9057\u7559\u95ee\u9898<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"http:\/\/dba.qishuo.xin\/?p=2616\/#21_%E8%A7%A3%E5%86%B3%E6%96%B9%E6%B3%95SOLUTION\" >2.1. \u89e3\u51b3\u65b9\u6cd5(SOLUTION)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"http:\/\/dba.qishuo.xin\/?p=2616\/#22_%E5%90%8E%E7%BB%AD%E8%B7%9F%E8%B8%AATRACKING\" >2.2. \u540e\u7eed\u8ddf\u8e2a(TRACKING)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"http:\/\/dba.qishuo.xin\/?p=2616\/#23_%E9%81%97%E7%95%99%E7%9A%84%E9%97%AE%E9%A2%98\" >2.3. \u9057\u7559\u7684\u95ee\u9898<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"http:\/\/dba.qishuo.xin\/?p=2616\/#3_%E7%BB%8F%E9%AA%8C%E6%80%BB%E7%BB%93SUMMARY\" >3. \u7ecf\u9a8c\u603b\u7ed3(SUMMARY)<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"http:\/\/dba.qishuo.xin\/?p=2616\/#31_%E7%BB%8F%E9%AA%8C%E4%B8%80\" >3.1. \u7ecf\u9a8c\u4e00<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"http:\/\/dba.qishuo.xin\/?p=2616\/#32_%E7%BB%8F%E9%AA%8C%E4%BA%8C\" >3.2. \u7ecf\u9a8c\u4e8c<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"http:\/\/dba.qishuo.xin\/?p=2616\/#%E9%99%84%E5%BD%95\" >\u9644\u5f55<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"http:\/\/dba.qishuo.xin\/?p=2616\/#%E9%99%84%E5%BD%95A_%E7%9B%B8%E5%85%B3%E8%81%94%E7%9A%84%E6%96%87%E7%AB%A0\" >\u9644\u5f55A. \u76f8\u5173\u8054\u7684\u6587\u7ae0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"http:\/\/dba.qishuo.xin\/?p=2616\/#%E9%99%84%E5%BD%95B_%E5%85%B6%E4%BB%96%E5%8F%82%E8%80%83\" >\u9644\u5f55B. \u5176\u4ed6\u53c2\u8003<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"http:\/\/dba.qishuo.xin\/?p=2616\/#%E9%99%84%E5%BD%95C_etcsecuritylimitsconf_%E9%85%8D%E7%BD%AE%E8%A7%A3%E6%9E%90\" >\u9644\u5f55C. \/etc\/security\/limits.conf \u914d\u7f6e\u89e3\u6790<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<p><strong>\u73af\u5883\u63cf\u8ff0<\/strong><\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left;\">\u63cf\u8ff0\u9879<\/th>\n<th style=\"text-align: left;\">\u5185\u5bb9<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left;\">\u64cd\u4f5c\u7cfb\u7edf<\/td>\n<td style=\"text-align: left;\"><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">java\u7248\u672c<\/td>\n<td style=\"text-align: left;\">java version &quot;1.8.0_161&quot;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3><span class=\"ez-toc-section\" id=\"1_%E6%95%85%E9%9A%9C%E7%8E%B0%E8%B1%A1%E4%B8%8E%E5%88%86%E6%9E%90\"><\/span>1. \u6545\u969c\u73b0\u8c61\u4e0e\u5206\u6790<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<h4><span class=\"ez-toc-section\" id=\"11_%E6%95%85%E9%9A%9C%E5%8F%91%E7%94%9F%E7%9A%84%E6%97%B6%E9%97%B4%E4%B8%8E%E7%8E%B0%E8%B1%A1SYMPTOMS\"><\/span>1.1. \u6545\u969c\u53d1\u751f\u7684\u65f6\u95f4\u4e0e\u73b0\u8c61(SYMPTOMS)<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>SpringBoot\u9879\u76ee\u5728\u542f\u52a8\u540e\u62a5\u5982\u4e0b\u9519\u8bef<\/p>\n<pre><code class=\"language-text\">Caused by: java.lang.OutOfMemoryError: unable to create new native thread\n    at java.lang.Thread.start0(Native Method)\n    at java.lang.Thread.start(Thread.java:719)\n    at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:957)\n    at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1367)\n    at org.apache.dubbo.remoting.transport.dispatcher.all.AllChannelHandler.received(AllChannelHandler.java:62)\n    ... 28 common frames omitted<\/code><\/pre>\n<p><a href=\"http:\/\/dba.qishuo.xin\/wp-content\/uploads\/2023\/01\/image-1673418110009.png\" data-fancybox=\"images\" data-fancybox=\"images\"><img decoding=\"async\" src=\"http:\/\/dba.qishuo.xin\/wp-content\/uploads\/2023\/01\/image-1673418110009.png\" alt=\"file\" \/><\/a><\/p>\n<h4><span class=\"ez-toc-section\" id=\"12_%E5%88%86%E6%9E%90%E8%BF%87%E7%A8%8BANALYSIS\"><\/span>1.2. \u5206\u6790\u8fc7\u7a0b(ANALYSIS)<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p><strong>1\uff09 \u627e\u5230\u8bf1\u53d1\u539f\u56e0\uff0c\u4e00\u822c\u7531\u4e8e\u4e24\u4e2a\u539f\u56e0\u5bfc\u81f4\u7684<\/strong><\/p>\n<ul>\n<li>\n<p><font color=red>\u5185\u5b58\u7a7a\u95f4\u4e0d\u8db3\u4ee5\u6ee1\u8db3\u521b\u5efa\u7ebf\u7a0b\u6240\u9700\u7684stack size<\/font><br \/>\n\u3000<code>virtual memory &lt; stack size*the number of threads<\/code><\/p>\n<\/li>\n<li>\n<p><font color=red>\u7ebf\u7a0b\u6570\u5df2\u8fbe\u5230\u64cd\u4f5c\u7cfb\u7edf\u8bbe\u5b9a\u7684<code>max user processes<\/code>\u4e0a\u9650<\/font><\/p>\n<\/li>\n<\/ul>\n<p><strong>2\uff09 \u67e5\u770b\u865a\u62df\u673ajvm<\/strong><\/p>\n<pre><code class=\"language-bash\">~]$ java -XX:+PrintFlagsFinal -version | grep ThreadStackSize\n     intx CompilerThreadStackSize                   = 0                                   {pd product}\n     intx ThreadStackSize                           = 1024                                {pd product}\n     intx VMThreadStackSize                         = 1024                                {pd product}\njava version &quot;1.8.0_351&quot;\nJava(TM) SE Runtime Environment (build 1.8.0_351-b10)\nJava HotSpot(TM) 64-Bit Server VM (build 25.351-b10, mixed mode)<\/code><\/pre>\n<p><strong>3\uff09\u67e5\u770b\u64cd\u4f5c\u7cfb\u7edf\u8fd0\u884c\u7a0b\u5e8f\u7684\u7528\u6237\u8d44\u6e90\u9650\u5236<\/strong><\/p>\n<pre><code class=\"language-bash\">\u8fdb\u7a0b\u53ef\u7528\u6700\u5927\u865a\u62df\u5185\u5b58\nulimit -v\n\n\u7ed3\u679c:unlimited\n\n\u6700\u5927\u6808\u5927\u5c0f\nulimit -s\n\n\u7ed3\u679c:8192\n\n\u6bcf\u4e2a\u7528\u6237\u53ef\u521b\u5efa\u6700\u5927\u8fdb\u7a0b\u6570\nulimit -u\n\n\u7ed3\u679c: 1024\n\n\u6574\u4f53\u4fe1\u606f\u67e5\u770b\nulimit -a\n\n\u7ed3\u679c\uff1a\ncore file size          (blocks, -c) unlimited\ndata seg size           (kbytes, -d) unlimited\nscheduling priority             (-e) 0\nfile size               (blocks, -f) unlimited\npending signals                 (-i) 514740\nmax locked memory       (kbytes, -l) 64\nmax memory size         (kbytes, -m) unlimited\nopen files                      (-n) 1048576\npipe size            (512 bytes, -p) 8\nPOSIX message queues     (bytes, -q) 819200\nreal-time priority              (-r) 0\nstack size              (kbytes, -s) 8192\ncpu time               (seconds, -t) unlimited\nmax user processes              (-u) 1024\nvirtual memory          (kbytes, -v) unlimited\nfile locks                      (-x) unlimited<\/code><\/pre>\n<p><strong>4\uff09\u67e5\u770b\u64cd\u4f5c\u7cfb\u7edf\u8fd0\u884c\u7a0b\u5e8f\u7684\u7528\u6237\u6253\u5f00\u7684\u6587\u4ef6\u6570<\/strong><\/p>\n<p><font color=red>\u5728Linux\u5e73\u53f0\u4e0a\uff0c\u65e0\u8bba\u7f16\u5199\u5ba2\u6237\u7aef\u7a0b\u5e8f\u8fd8\u662f\u670d\u52a1\u7aef\u7a0b\u5e8f\uff0c\u5728\u8fdb\u884c\u9ad8\u5e76\u53d1TCP\u8fde\u63a5\u5904\u7406\u65f6\uff0c\u6700\u9ad8\u7684\u5e76\u53d1\u6570\u91cf\u90fd\u8981\u53d7\u5230\u7cfb\u7edf\u5bf9\u7528\u6237\u5355\u4e00\u8fdb\u7a0b\u540c\u65f6\u53ef\u6253\u5f00\u6587\u4ef6\u6570\u91cf\u7684\u9650\u5236\uff08\u8fd9\u662f\u56e0\u4e3a\u7cfb\u7edf\u4e3a\u6bcf\u4e2aTCP\u8fde\u63a5\u90fd\u8981\u521b\u5efa\u4e00\u4e2asocket\u53e5\u67c4\uff0c\u6bcf\u4e2asocket\u53e5\u67c4\u540c\u65f6\u4e5f\u662f\u4e00\u4e2a\u6587\u4ef6\u53e5\u67c4\uff09\u3002<\/font><\/p>\n<pre><code class=\"language-bash\">[shell]\n# \u67e5\u770b\u5f53\u524d\u7528\u6237\u6240\u6709\u8fdb\u7a0b\u6253\u5f00\u7684\u6587\u4ef6\u6570\nlsof | wc -l\n# \u67e5\u770b\u67d0\u4e00\u8fdb\u7a0b\u6253\u5f00\u7684\u6587\u4ef6\u6570\nlsof -p pid | wc -l\n# \u67e5\u770b\u67d0\u4e00\u8fdb\u7a0b\u4e0b\u7684\u7ebf\u7a0b\npstree -p pid\n# \u7edf\u8ba1\u67d0\u4e00\u8fdb\u7a0b\u4e0b\u7684\u7ebf\u7a0b\u6570\npstree -p pid | wc -l<\/code><\/pre>\n<p><a href=\"http:\/\/dba.qishuo.xin\/wp-content\/uploads\/2023\/01\/image-1673846858213.png\" data-fancybox=\"images\" data-fancybox=\"images\"><img decoding=\"async\" src=\"http:\/\/dba.qishuo.xin\/wp-content\/uploads\/2023\/01\/image-1673846858213.png\" alt=\"file\" \/><\/a><\/p>\n<p><strong>5\uff09 \u67e5\u770b\u5185\u5b58\u60c5\u51b5<\/strong><\/p>\n<pre><code class=\"language-bash\">[shell]\nfree -m<\/code><\/pre>\n<p><a href=\"http:\/\/dba.qishuo.xin\/wp-content\/uploads\/2023\/01\/image-1673847162196.png\" data-fancybox=\"images\" data-fancybox=\"images\"><img decoding=\"async\" src=\"http:\/\/dba.qishuo.xin\/wp-content\/uploads\/2023\/01\/image-1673847162196.png\" alt=\"file\" \/><\/a><\/p>\n<ul>\n<li>\u67e5\u770b\u5360\u7528swap\u524dN\u7684\u7a0b\u5e8f\u7684PID\u548c\u5360\u7528\u5185\u5b58\n<pre><code class=\"language-bash\">[shell]\nfor i in $( cd \/proc;ls |grep &quot;^[0-9]&quot;|awk &#039; $0 &gt;100&#039;) ;do awk &#039;\/Swap:\/{a=a+$2}END{print &#039;&quot;$i&quot;&#039;,a\/1024&quot;M&quot;}&#039; \/proc\/$i\/smaps 2&gt;\/dev\/null ; done | sort -k2nr | head -10<\/code><\/pre>\n<\/li>\n<\/ul>\n<p><a href=\"http:\/\/dba.qishuo.xin\/wp-content\/uploads\/2023\/01\/image-1673847952175.png\" data-fancybox=\"images\" data-fancybox=\"images\"><img decoding=\"async\" src=\"http:\/\/dba.qishuo.xin\/wp-content\/uploads\/2023\/01\/image-1673847952175.png\" alt=\"file\" \/><\/a><br \/>\n\u8fd9\u91cc\u6ca1\u6709\u4f7f\u7528swap\u7a7a\u95f4\uff0c\u5982\u679c\u6709\u7684\u8bdd\u53ef\u4ee5\u6839\u636ePID\u67e5\u770b\u5177\u4f53\u7684\u8fdb\u7a0b\u3002<\/p>\n<h4><span class=\"ez-toc-section\" id=\"13_%E6%A0%B9%E6%9C%AC%E5%8E%9F%E5%9B%A0CAUSE\"><\/span>1.3. \u6839\u672c\u539f\u56e0(CAUSE)<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p><strong><font color=red>\u8fd0\u884c\u7a0b\u5e8f\u7684\u7528\u6237\u6240\u80fd\u6253\u5f00\u7684\u6700\u5927\u6587\u4ef6\u6570\u8fc7\u5c0f\u5bfc\u81f4\u8d44\u6e90\u8017\u5c3d\u3002<\/font><\/strong><\/p>\n<h3><span class=\"ez-toc-section\" id=\"2_%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88%E4%B8%8E%E9%81%97%E7%95%99%E9%97%AE%E9%A2%98\"><\/span>2. \u89e3\u51b3\u65b9\u6848\u4e0e\u9057\u7559\u95ee\u9898<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<h4><span class=\"ez-toc-section\" id=\"21_%E8%A7%A3%E5%86%B3%E6%96%B9%E6%B3%95SOLUTION\"><\/span>2.1. \u89e3\u51b3\u65b9\u6cd5(SOLUTION)<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>\u5728 <code>\/etc\/security\/limits.d\/<\/code> \u76ee\u5f55\u4e0b\u521b\u5efa\u6587\u4ef6 <code>20-nproc.conf<\/code>,\u5176\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-text\"># Default limit for number of user&#039;s processes to prevent\n# accidental fork bombs.\n# See rhbz #432903 for reasoning.\n\n# \u6240\u6709\u7684\u7528\u6237\u9ed8\u8ba4\u53ef\u4ee5\u6253\u5f00\u6700\u5927\u7684\u8fdb\u7a0b\u6570\u4e3a 8192\n*          soft    nproc     8192\n\n# root \u7528\u6237\u9ed8\u8ba4\u53ef\u4ee5\u6253\u5f00\u6700\u5927\u7684\u8fdb\u7a0b\u6570 \u65e0\u9650\u5236\u7684\u3002\nroot       soft    nproc     unlimited<\/code><\/pre>\n<p><font color=red>\u6ce8\u610f\u4e8b\u9879\uff1a<\/font><\/p>\n<ol>\n<li>\u8986\u76d6\u70b9\u95ee\u9898\uff1a<code>\/etc\/security\/limits.d\/<\/code> \u4e0b\u6587\u4ef6\u7684\u76f8\u540c\u914d\u7f6e\u53ef\u4ee5\u8986\u76d6 <code>\/etc\/security\/limits.conf<\/code> \u91cc\u7684\u5185\u5bb9\u3002<\/li>\n<li><code>nofile<\/code>\u4e0d\u80fd\u8bbe\u7f6e <code>unlimited<\/code>\u3002<\/li>\n<li><code>nofile<\/code>\u53ef\u4ee5\u8bbe\u7f6e\u7684\u6700\u5927\u503c\u4e3a <code>1048576(2**20)<\/code>\uff0c\u8bbe\u7f6e\u7684\u503c\u5927\u4e8e\u8be5\u6570\uff0c\u5c31\u4f1a\u8fdb\u884c\u767b\u5f55\u4e0d\u4e86\u3002<\/li>\n<li><code>soft<\/code> \u8bbe\u7f6e\u7684\u503c\u4e00\u5b9a\u8981\u5c0f\u4e8e\u6216\u7b49\u4e8e <code>hard<\/code> \u7684\u503c\u3002<\/li>\n<li>\u8bbe\u7f6e\u4e86\u8d44\u6e90\u9650\u5236\u540e\uff0c\u9700\u8981linux\u7528\u6237\u91cd\u65b0\u767b\u5f55\u6216\u91cd\u542f\u670d\u52a1\u5668\u624d\u4f1a\u751f\u6548\u3002<\/li>\n<\/ol>\n<h4><span class=\"ez-toc-section\" id=\"22_%E5%90%8E%E7%BB%AD%E8%B7%9F%E8%B8%AATRACKING\"><\/span>2.2. \u540e\u7eed\u8ddf\u8e2a(TRACKING)<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<ul>\n<li>\u67e5\u770b\u7528\u6237\u5f53\u524d\u7684\u8d44\u6e90\u914d\u7f6e\n<pre><code>~]$ ulimit -a\ncore file size          (blocks, -c) 0\ndata seg size           (kbytes, -d) unlimited\nscheduling priority             (-e) 0\nfile size               (blocks, -f) unlimited\npending signals                 (-i) 128305\nmax locked memory       (kbytes, -l) 64\nmax memory size         (kbytes, -m) unlimited\nopen files                      (-n) 204800\npipe size            (512 bytes, -p) 8\nPOSIX message queues     (bytes, -q) 819200\nreal-time priority              (-r) 0\nstack size              (kbytes, -s) 10240\ncpu time               (seconds, -t) unlimited\nmax user processes              (-u) 8192\nvirtual memory          (kbytes, -v) unlimited\nfile locks                      (-x) unlimited<\/code><\/pre>\n<\/li>\n<\/ul>\n<h4><span class=\"ez-toc-section\" id=\"23_%E9%81%97%E7%95%99%E7%9A%84%E9%97%AE%E9%A2%98\"><\/span>2.3. \u9057\u7559\u7684\u95ee\u9898<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>\u65e0<\/p>\n<h3><span class=\"ez-toc-section\" id=\"3_%E7%BB%8F%E9%AA%8C%E6%80%BB%E7%BB%93SUMMARY\"><\/span>3. \u7ecf\u9a8c\u603b\u7ed3(SUMMARY)<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<h4><span class=\"ez-toc-section\" id=\"31_%E7%BB%8F%E9%AA%8C%E4%B8%80\"><\/span>3.1. \u7ecf\u9a8c\u4e00<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>\u5206\u6790\u95ee\u9898\u8981\u4e00\u9879\u4e00\u9879\u8fdb\u884c\u6392\u9664\uff0c\u4e0d\u80fd\u76f2\u76ee\u53bb\u778e\u731c\u3002<\/p>\n<h4><span class=\"ez-toc-section\" id=\"32_%E7%BB%8F%E9%AA%8C%E4%BA%8C\"><\/span>3.2. \u7ecf\u9a8c\u4e8c<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<h3><span class=\"ez-toc-section\" id=\"%E9%99%84%E5%BD%95\"><\/span>\u9644\u5f55<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<h4><span class=\"ez-toc-section\" id=\"%E9%99%84%E5%BD%95A_%E7%9B%B8%E5%85%B3%E8%81%94%E7%9A%84%E6%96%87%E7%AB%A0\"><\/span>\u9644\u5f55A. \u76f8\u5173\u8054\u7684\u6587\u7ae0<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<h4><span class=\"ez-toc-section\" id=\"%E9%99%84%E5%BD%95B_%E5%85%B6%E4%BB%96%E5%8F%82%E8%80%83\"><\/span>\u9644\u5f55B. \u5176\u4ed6\u53c2\u8003<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<ul>\n<li>\n<p><a target=\"_blank\" href=\"https:\/\/blog.csdn.net\/bowenlaw\/article\/details\/111031120\" title=\"\u89e3\u51b3 java.lang.OutOfMemoryError: unable to create new native thread\">\u89e3\u51b3 java.lang.OutOfMemoryError: unable to create new native thread<\/a><\/p>\n<\/li>\n<li>\n<p><a target=\"_blank\" href=\"https:\/\/www.cnblogs.com\/operationhome\/p\/11966041.html\" title=\"\/etc\/security\/limits.conf \u8be6\u89e3\u4e0e\u914d\u7f6e\">\/etc\/security\/limits.conf \u8be6\u89e3\u4e0e\u914d\u7f6e<\/a><\/p>\n<\/li>\n<li>\n<p><a target=\"_blank\" href=\"https:\/\/www.linuxtop.cn\/command\/top.html\" title=\"Linux\u5e38\u7528\u547d\u4ee4-top\">Linux\u5e38\u7528\u547d\u4ee4-top<\/a><\/p>\n<\/li>\n<\/ul>\n<h4><span class=\"ez-toc-section\" id=\"%E9%99%84%E5%BD%95C_etcsecuritylimitsconf_%E9%85%8D%E7%BD%AE%E8%A7%A3%E6%9E%90\"><\/span>\u9644\u5f55C. <code>\/etc\/security\/limits.conf<\/code> \u914d\u7f6e\u89e3\u6790<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<pre><code class=\"language-text\"># \/etc\/security\/limits.conf\n#\n#This file sets the resource limits for the users logged in via PAM.\n\u8be5\u6587\u4ef6\u4e3a\u901a\u8fc7PAM\u767b\u5f55\u7684\u7528\u6237\u8bbe\u7f6e\u8d44\u6e90\u9650\u5236\u3002\n#It does not affect resource limits of the system services.\n#\u5b83\u4e0d\u5f71\u54cd\u7cfb\u7edf\u670d\u52a1\u7684\u8d44\u6e90\u9650\u5236\u3002\n#Also note that configuration files in \/etc\/security\/limits.d directory,\n#which are read in alphabetical order, override the settings in this\n#file in case the domain is the same or more specific.\n\u8bf7\u6ce8\u610f\/etc\/security\/limits.d\u4e0b\u6309\u7167\u5b57\u6bcd\u987a\u5e8f\u6392\u5217\u7684\u914d\u7f6e\u6587\u4ef6\u4f1a\u8986\u76d6 \/etc\/security\/limits.conf\u4e2d\u7684\ndomain\u76f8\u540c\u7684\u7684\u914d\u7f6e\n#That means for example that setting a limit for wildcard domain here\n#can be overriden with a wildcard setting in a config file in the\n#subdirectory, but a user specific setting here can be overriden only\n#with a user specific setting in the subdirectory.\n\u8fd9\u610f\u5473\u7740\uff0c\u4f8b\u5982\u4f7f\u7528\u901a\u914d\u7b26\u7684domain\u4f1a\u88ab\u5b50\u76ee\u5f55\u4e2d\u76f8\u540c\u7684\u901a\u914d\u7b26\u914d\u7f6e\u6240\u8986\u76d6\uff0c\u4f46\u662f\u67d0\u4e00\u7528\u6237\u7684\u7279\u5b9a\u914d\u7f6e\n\u53ea\u80fd\u88ab\u5b57\u6bcd\u8def\u4e2d\u7528\u6237\u7684\u914d\u7f6e\u6240\u8986\u76d6\u3002\u5176\u5b9e\u5c31\u662f\u67d0\u4e00\u7528\u6237A\u5982\u679c\u5728\/etc\/security\/limits.conf\u6709\u914d\u7f6e\uff0c\u5f53\n\/etc\/security\/limits.d\u5b50\u76ee\u5f55\u4e0b\u914d\u7f6e\u6587\u4ef6\u4e5f\u6709\u7528\u6237A\u7684\u914d\u7f6e\u65f6\uff0c\u90a3\u4e48A\u4e2d\u67d0\u4e9b\u914d\u7f6e\u4f1a\u88ab\u8986\u76d6\u3002\u6700\u7ec8\u53d6\u7684\u503c\u662f \/etc\/security\/limits.d \u4e0b\u7684\u914d\u7f6e\u6587\u4ef6\u7684\u914d\u7f6e\u3002\n\n#\n#Each line describes a limit for a user in the form:\n#\u6bcf\u4e00\u884c\u63cf\u8ff0\u4e00\u4e2a\u7528\u6237\u914d\u7f6e\n#&lt;domain&gt; &lt;type&gt; &lt;item&gt; &lt;value&gt;\n\n#Where:\n#&lt;domain&gt; can be:\n# - a user name    \u4e00\u4e2a\u7528\u6237\u540d\n# - a group name, with @group syntax    \u7528\u6237\u7ec4\u683c\u5f0f\u4e3a@GROUP_NAME\n# - the wildcard *, for default entry    \u9ed8\u8ba4\u914d\u7f6e\u4e3a*\uff0c\u4ee3\u8868\u6240\u6709\u7528\u6237\n# - the wildcard %, can be also used with %group syntax,\n# for maxlogin limit\n#\n#&lt;type&gt; can have the two values:\n# - &quot;soft&quot; for enforcing the soft limits\n# - &quot;hard&quot; for enforcing hard limits\n\u6709soft\uff0chard\u548c-\uff0csoft\u6307\u7684\u662f\u5f53\u524d\u7cfb\u7edf\u751f\u6548\u7684\u8bbe\u7f6e\u503c\uff0c\u8f6f\u9650\u5236\u4e5f\u53ef\u4ee5\u7406\u89e3\u4e3a\u8b66\u544a\u503c\u3002\nhard\u8868\u660e\u7cfb\u7edf\u4e2d\u6240\u80fd\u8bbe\u5b9a\u7684\u6700\u5927\u503c\u3002soft\u7684\u9650\u5236\u4e0d\u80fd\u6bd4hard\u9650\u5236\u9ad8\uff0c\u7528-\u8868\u540d\u540c\u65f6\u8bbe\u7f6e\u4e86soft\u548chard\u7684\u503c\u3002\n#&lt;item&gt; can be one of the following:    &lt;item&gt;\u53ef\u4ee5\u4f7f\u4ee5\u4e0b\u9009\u9879\u4e2d\u7684\u4e00\u4e2a\n# - core - limits the core file size (KB)    \u9650\u5236\u5185\u6838\u6587\u4ef6\u7684\u5927\u5c0f\u3002\n# - data - max data size (KB)    \u6700\u5927\u6570\u636e\u5927\u5c0f\n# - fsize - maximum filesize (KB)    \u6700\u5927\u6587\u4ef6\u5927\u5c0f\n# - memlock - max locked-in-memory address space (KB)    \u6700\u5927\u9501\u5b9a\u5185\u5b58\u5730\u5740\u7a7a\u95f4\n# - nofile - max number of open file descriptors \u6700\u5927\u6253\u5f00\u7684\u6587\u4ef6\u6570(\u4ee5\u6587\u4ef6\u63cf\u53d9\u7b26\uff0cfile descripter\u8ba1\u6570)\n# - rss - max resident set size (KB) \u6700\u5927\u6301\u4e45\u8bbe\u7f6e\u5927\u5c0f\n# - stack - max stack size (KB) \u6700\u5927\u6808\u5927\u5c0f\n# - cpu - max CPU time (MIN)    \u6700\u591aCPU\u5360\u7528\u65f6\u95f4\uff0c\u5355\u4f4d\u4e3aMIN\u5206\u949f\n# - nproc - max number of processes \u8fdb\u7a0b\u7684\u6700\u5927\u6570\u76ee\n# - as - address space limit (KB) \u5730\u5740\u7a7a\u95f4\u9650\u5236\n# - maxlogins - max number of logins for this user    \u6b64\u7528\u6237\u5141\u8bb8\u767b\u5f55\u7684\u6700\u5927\u6570\u76ee\n# - maxsyslogins - max number of logins on the system    \u7cfb\u7edf\u6700\u5927\u540c\u65f6\u5728\u7ebf\u7528\u6237\u6570\n# - priority - the priority to run user process with    \u8fd0\u884c\u7528\u6237\u8fdb\u7a0b\u7684\u4f18\u5148\u7ea7\n# - locks - max number of file locks the user can hold    \u7528\u6237\u53ef\u4ee5\u6301\u6709\u7684\u6587\u4ef6\u9501\u7684\u6700\u5927\u6570\u91cf\n# - sigpending - max number of pending signals\n# - msgqueue - max memory used by POSIX message queues (bytes)\n# - nice - max nice priority allowed to raise to values: [-20, 19] max nice\u4f18\u5148\u7ea7\u5141\u8bb8\u63d0\u5347\u5230\u503c\n# - rtprio - max realtime pr iority\n#\n#&lt;domain&gt; &lt;type&gt; &lt;item&gt; &lt;value&gt;\n#\n\n#* soft core 0\n#* hard rss 10000\n#@student hard nproc 20\n#@faculty soft nproc 20\n#@faculty hard nproc 50\n#ftp hard nproc 0\n#@st<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u73af\u5883\u63cf\u8ff0 \u63cf\u8ff0\u9879 \u5185\u5bb9 \u64cd\u4f5c\u7cfb\u7edf java\u7248\u672c j&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[178],"tags":[179,243,245],"class_list":["post-2616","post","type-post","status-publish","format-standard","hentry","category-java","tag-java","tag-outofmemoryerror","tag-ulimit"],"_links":{"self":[{"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/posts\/2616","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2616"}],"version-history":[{"count":15,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/posts\/2616\/revisions"}],"predecessor-version":[{"id":2686,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/posts\/2616\/revisions\/2686"}],"wp:attachment":[{"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2616"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2616"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2616"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}