Linux 下tomcat 出現 java.lang.OutOfMemoryError: unable to create new native thread,createnativethread

來源:互聯網
上載者:User

Linux 下tomcat 出現 java.lang.OutOfMemoryError: unable to create new native thread,createnativethread

問題現象:

Tomcat(8.5.13)部署了SuperMap iServer,並發使用者在100左右。系統運行一段時間後,服務崩潰。異常提示

問題分析:

1、看到日誌中的提示資訊後,認為是系統記憶體不足導致的。於是在伺服器上添加了監控指令碼(如),每1s記錄一次系統記憶體和tomcat記憶體。

監控一段時間後,異常再次出現。從日誌中並未發現記憶體異常

2、記憶體排除後,思路轉到是否是由於並發使用者數太多,導致的進程數超出呢?

 1)查看linux 目前使用者的資源限制參數 ulimit -a

2)在上面這些參數中,關注得比較多的是一個進程可開啟的最大檔案數,即open files。系統允許建立的最大進程數量即是max user processes 這個參數。 我們可以使用 ulimit -u 4096 修改max user processes的值,但是只能在當前終端的這個session裡面生效,重新登入後仍然是使用系統預設值。

正確的修改方式是修改/etc/security/limits.d/90-nproc.conf檔案中的值。先看一下這個檔案包含什麼:

$ cat /etc/security/limits.d/90-nproc.conf # Default limit for number of user's processes to prevent# accidental fork bombs.# See rhbz #432903 for reasoning.*          soft    nproc    4096

我們只要修改上面檔案中的4096這個值,即可。

經過排查,確實是由於伺服器目前使用者設定的最大進程數設定太小導致的無法建立進程,崩潰。

 

參考:http://www.linuxidc.com/Linux/2011-03/33121.htm

http://www.cnblogs.com/billyxp/archive/2013/04/03/2998079.html

linux 查看當前進程:http://os.51cto.com/art/201101/244090.htm

http://www.linuxidc.com/Linux/2015-01/111270.htm

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.