Skip to content
This repository has been archived by the owner on Dec 22, 2023. It is now read-only.

Wabisabi Client creating threads and not cleaning them #54

Open
viktomas opened this issue Jul 12, 2017 · 1 comment
Open

Wabisabi Client creating threads and not cleaning them #54

viktomas opened this issue Jul 12, 2017 · 1 comment

Comments

@viktomas
Copy link

In scala we are crating temporary wabisabi.Client object and then loosing reference to it (expecting GC to free the memory). This object creation spawns 20+ threads that are never going to be finished and so after few hundred constructor invocations we end up with error:

java.lang.OutOfMemoryError: unable to create new native thread
	at java.lang.Thread.start0(Native Method)
	at java.lang.Thread.start(Thread.java:714)
	at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:950)
	at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1368)
	at org.jboss.netty.util.internal.DeadLockProofWorker.start(DeadLockProofWorker.java:38)
	at org.jboss.netty.channel.socket.nio.AbstractNioSelector.openSelector(AbstractNioSelector.java:368)
	at org.jboss.netty.channel.socket.nio.AbstractNioSelector.<init>(AbstractNioSelector.java:100)
	at org.jboss.netty.channel.socket.nio.AbstractNioWorker.<init>(AbstractNioWorker.java:52)
	at org.jboss.netty.channel.socket.nio.NioWorker.<init>(NioWorker.java:45)
	at org.jboss.netty.channel.socket.nio.NioWorkerPool.newWorker(NioWorkerPool.java:44)
	at org.jboss.netty.channel.socket.nio.NioWorkerPool.newWorker(NioWorkerPool.java:28)
	at org.jboss.netty.channel.socket.nio.AbstractNioWorkerPool.init(AbstractNioWorkerPool.java:80)
	at org.jboss.netty.channel.socket.nio.NioWorkerPool.<init>(NioWorkerPool.java:39)
	at org.jboss.netty.channel.socket.nio.NioWorkerPool.<init>(NioWorkerPool.java:33)
	at org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory.<init>(NioClientSocketChannelFactory.java:151)
	at org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory.<init>(NioClientSocketChannelFactory.java:133)
	at com.ning.http.client.providers.netty.channel.ChannelManager.<init>(ChannelManager.java:178)
	at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.<init>(NettyAsyncHttpProvider.java:56)
	at sun.reflect.GeneratedConstructorAccessor19.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at com.ning.http.client.AsyncHttpClient.loadDefaultProvider(AsyncHttpClient.java:544)
	at com.ning.http.client.AsyncHttpClient.<init>(AsyncHttpClient.java:187)
	at dispatch.Http.configure(execution.scala:21)
	at wabisabi.Client.<init>(Client.scala:14)

example of threads created:
screen shot 2017-07-12 at 10 39 12 pm

chart showing rapid increase in number of live threads
screen shot 2017-07-12 at 10 39 24 pm

@viktomas
Copy link
Author

Possible solution to this might be accepting an ExecutionContext when creating wabisabi client

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant