<br><br><div class="gmail_quote">On Wed, Jun 22, 2011 at 6:18 PM, Johnny Luong <span dir="ltr">&lt;<a href="mailto:johnny.luong@trustcommerce.com">johnny.luong@trustcommerce.com</a>&gt;</span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi,<br>
<br>
If you take a look at the javadoc for NioServerSocketChannelFactory,<br>
you&#39;ll see a section underneath about how it deals with the threading<br>
which I think explains what you are seeing.<br>
<br>
<a href="http://docs.jboss.org/netty/3.2/api/org/jboss/netty/channel/socket/nio/NioServerSocketChannelFactory.html" target="_blank">http://docs.jboss.org/netty/3.2/api/org/jboss/netty/channel/socket/nio/NioServerSocketChannelFactory.html</a><br>

<br>
The threads that are used for doing the &quot;work&quot; are not the same ones as<br>
the ones doing accept calls on each of the bound ports.<br>
<br>
- -Johnny</blockquote></div><div><br></div><div>Right, I get that much.</div><div><br></div><div>Is there no way to limit thread usage? Having thousands of mostly-idle threads ends up consuming quite a bit of memory.</div>
<div><br></div><div>I was hoping to use a handful of threads for the entire application, not strictly one per server port.</div><div><br></div><div>Here&#39;s some sample code:</div><div> <a href="https://github.com/jordansissel/experiments/blob/master/java/netty/manysockets/ServerTest.java">https://github.com/jordansissel/experiments/blob/master/java/netty/manysockets/ServerTest.java</a></div>
<div><br></div><div>When this runs, it uses about 1.4GB of memory only having started the server sockets - that&#39;s pretty huge - only listening on 1 port results in 26mb used total by the process:</div><div><br></div><div>
% ps -o rss,args -p 4414</div><div>  RSS COMMAND</div><div>1416232 java -cp netty-3.2.4.Final.jar:build ServerTest</div><div><br></div><div>What are my options here?</div><div><br></div><div>-Jordan</div>