Troubleshooting irregular OutOfMemoryError: unable to create new native thread
Troubleshooting irregular OutOfMemoryError: unable to create new native thread
我有一个 Ubuntu 16.04.5 服务器,其中 运行 多个 Java 应用程序作为 root。应用程序定期(大约每 30 分钟到 1 小时)从 OutOfMemoryError: unable to create new native thread
崩溃。我注意到,应用程序不会单独崩溃,而是多个应用程序同时崩溃。
我不知道是什么原因导致的,我很难找到我需要更改什么来解决这个问题。
我关注了一些关于该错误的文章并分析了多个 os 可能的原因,但它们似乎不适用于我的情况:
修复线程创建率
应用程序定期创建线程,但也有许多线程死亡。这意味着并发线程数永远不会超过 10k。我通过生成线程转储和计算线程来检查 运行 离开线程创建是否有问题,但线程数从未超过前面提到的 10k。
增加 os
的线程限制
当我运行ulimit -u
它returns1546669
.
这应该够了吧?
为机器分配更多 RAM
我使用了大约 7GB 的可用 16GB RAM。这是我的 htop 视图:
附加信息
Java版本:
错误的完整错误堆栈跟踪:
java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Thread.java:717)
at de.domisum.lib.auxilium.util.java.ThreadUtil.createAndStartThread(ThreadUtil.java:126)
at de.domisum.lib.auxilium.util.java.ThreadUtil.createAndStartThread(ThreadUtil.java:114)
at de.domisum.lib.auxilium.run.RunNotifyOnTimeout.run(RunNotifyOnTimeout.java:32)
at de.domisum.lib.auxilium.util.ticker.Ticker.tickWithTimeout(Ticker.java:119)
at de.domisum.lib.auxilium.util.ticker.Ticker.run(Ticker.java:108)
at java.lang.Thread.run(Thread.java:748)
来自出现以下错误的应用程序的线程转储:thread dump
迁移到 Java11 后问题消失了。
我有一个 Ubuntu 16.04.5 服务器,其中 运行 多个 Java 应用程序作为 root。应用程序定期(大约每 30 分钟到 1 小时)从 OutOfMemoryError: unable to create new native thread
崩溃。我注意到,应用程序不会单独崩溃,而是多个应用程序同时崩溃。
我不知道是什么原因导致的,我很难找到我需要更改什么来解决这个问题。
我关注了一些关于该错误的文章并分析了多个 os 可能的原因,但它们似乎不适用于我的情况:
修复线程创建率
应用程序定期创建线程,但也有许多线程死亡。这意味着并发线程数永远不会超过 10k。我通过生成线程转储和计算线程来检查 运行 离开线程创建是否有问题,但线程数从未超过前面提到的 10k。
增加 os
的线程限制当我运行ulimit -u
它returns1546669
.
这应该够了吧?
为机器分配更多 RAM
我使用了大约 7GB 的可用 16GB RAM。这是我的 htop 视图:
附加信息
Java版本:
错误的完整错误堆栈跟踪:
java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Thread.java:717)
at de.domisum.lib.auxilium.util.java.ThreadUtil.createAndStartThread(ThreadUtil.java:126)
at de.domisum.lib.auxilium.util.java.ThreadUtil.createAndStartThread(ThreadUtil.java:114)
at de.domisum.lib.auxilium.run.RunNotifyOnTimeout.run(RunNotifyOnTimeout.java:32)
at de.domisum.lib.auxilium.util.ticker.Ticker.tickWithTimeout(Ticker.java:119)
at de.domisum.lib.auxilium.util.ticker.Ticker.run(Ticker.java:108)
at java.lang.Thread.run(Thread.java:748)
来自出现以下错误的应用程序的线程转储:thread dump
迁移到 Java11 后问题消失了。