最近项目中,遇到一个报错:java.lang.OutOfMemoryError: unable to create new native thread报错的场景是:一个消息的群发,群里总共有50多个人,一群发 tomcat 就崩溃了,查看日志报上面的错误。这个错误的基本情况是,没 ...
最近项目中,遇到一个报错:
java.lang.OutOfMemoryError: unable to create new native thread
报错的场景是:一个消息的群发,群里总共有50多个人,一群发 tomcat 就崩溃了,查看日志报上面的错误。
这个错误的基本情况是,没有内存来创建新的本地线程了,因为java中创建的线程,最终是要对应到本地线程。基本的解决方法,是减小:xss 的数值,页就是减小 java 线程stack 占用内存的大小,一般可以改小到 128k。
关于这个错误网上有一篇博文可以参考:http://sesame.iteye.com/blog/622670
http://stackoverflow.com/ 上也有很多分析好答案。
You have a chance to face the java.lang.OutOfMemoryError: Unable to create new native thread whenever the JVM asks for a new thread from the OS. Whenever the underlying OS cannot allocate a new native thread, this OutOfMemoryError will be thrown. The exact limit for native threads is very platform-dependent thus we recommend to find out those limits by running a test similar to the below example.
重现错误:
public static void main(String[] args) { LongAdder adder = new LongAdder(); while(true){ new Thread(new Runnable(){ public void run() { try { adder.increment(); Thread.sleep(10000000); } catch(InterruptedException e) { } } }).start(); System.out.println(adder.longValue()); } }
海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com
原标题:HttpsURLConnection 利用keepAlive特性进行优化一例
关键词:URL
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。