“java.lang.OutOfMemoryError : unable to create new native Thread”

今天遇到这个异常

 message=500com.duitang.dboss.remote.oio.DbossException: java.lang.reflect.InvocationTargetException
	at com.duitang.dboss.service.ServiceInvoker.doaccept2(ServiceInvoker.java:136)
	at com.duitang.dboss.service.ServiceInvoker.accept(ServiceInvoker.java:46)
	at com.duitang.dboss.remote.nio.DbossServerHandler.messageReceived(DbossServerHandler.java:40)
	at org.jboss.netty.channel.SimpleChannelHandler.handleUpstream(SimpleChannelHandler.java:98)
	at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:560)
	at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:796)
	at org.jboss.netty.handler.execution.ChannelEventRunnable.run(ChannelEventRunnable.java:69)
	at org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor$ChildExecutor.run(OrderedMemoryAwareThreadPoolExecutor.java:307)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at com.duitang.dboss.service.ServiceInvoker.doaccept2(ServiceInvoker.java:127)
	... 10 more
Caused by: java.lang.OutOfMemoryError: unable to create new native thread
	at java.lang.Thread.start0(Native Method)
	at java.lang.Thread.start(Thread.java:640)
	at java.util.concurrent.ThreadPoolExecutor.addIfUnderMaximumPoolSize(ThreadPoolExecutor.java:727)
	at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:657)
	at java.util.concurrent.AbstractExecutorService.invokeAll(AbstractExecutorService.java:200)
	at com.duitang.common.authen.UserUtils.queryUserById(UserUtils.java:89)
	at com.duitang.biz.user.impl.UserQueryServiceImpl.queryUserById(UserQueryServiceImpl.java:117)
	at com.duitang.biz.user.impl.UserQueryServiceImpl.queryPeopleById(UserQueryServiceImpl.java:171)
	... 15 more

stackoverflow说是ulimit的问题:http://stackoverflow.com/questions/16789288/java-lang-outofmemoryerror-unable-to-create-new-native-thread

线上这台机器是新装的,果然是max user processes被默认限制为1024了。解决办法是:

修改 /etc/security/limits.d/90-nproc.conf ,把默认的1024修改为unlimited

关于ulimit的限制,更多参考:

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

http://blog.yufeng.info/archives/2568

你可能感兴趣的:(“java.lang.OutOfMemoryError : unable to create new native Thread”)