<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-US link=blue vlink=purple>

<div class=WordSection1>

<p class=MsoNormal>Hi everyone,<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>I am experiencing out of memory issues with Netty when it is
used as a proxy server with NIO.&nbsp; <o:p></o:p></p>

<p class=MsoNormal><span style='color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>Jul 29, 2010 2:13:54 PM
org.jboss.netty.channel.socket.nio.NioWorker</span><span style='font-size:10.0pt;
font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>WARNING: Unexpected exception in the
selector loop.</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>java.lang.OutOfMemoryError: Java heap
space</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at
org.jboss.netty.buffer.HeapChannelBuffer.&lt;init&gt;(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>HeapChannelBuffer.java:49</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at
org.jboss.netty.buffer.BigEndianHeapChannelBuffer.&lt;init&gt;(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>BigEndianHeapChannelBuffer.java:39</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at
org.jboss.netty.buffer.ChannelBuffers.buffer(</span><u><span style='font-size:
10.0pt;font-family:"Courier New";color:navy'>ChannelBuffers.java:131</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at
org.jboss.netty.buffer.HeapChannelBufferFactory.getBuffer(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>HeapChannelBufferFactory.java:72</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at
org.jboss.netty.buffer.AbstractChannelBufferFactory.getBuffer(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>AbstractChannelBufferFactory.java:53</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at
org.jboss.netty.channel.socket.nio.NioWorker.read(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>NioWorker.java:298</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at
org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>NioWorker.java:275</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at
org.jboss.netty.channel.socket.nio.NioWorker.run(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>NioWorker.java:196</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at
org.jboss.netty.util.internal.IoWorkerRunnable.run(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>IoWorkerRunnable.java:46</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>ThreadPoolExecutor.java:886</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at
java.util.concurrent.ThreadPoolExecutor$Worker.run(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>ThreadPoolExecutor.java:908</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New";
color:red'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at java.lang.Thread.run(</span><u><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>Thread.java:619</span></u><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>)<o:p></o:p></span></p>

<p class=MsoNormal><span style='color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal>I have an example program that I would like to send, but
I&#8217;m not sure if I can send it directly to the user mailing list, or if I
must open a case in order post the code.&nbsp; Please advise.<span
style='color:#1F497D'><o:p></o:p></span></p>

<p class=MsoNormal><span style='color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal>In my example, I have a simple TestServer and TestClient.&nbsp;
The server is a simple server based on plain old Java sockets.&nbsp; When the
TestClient downloads directly (no proxy) from the TestServer with 5 or so
concurrent clients, the files are downloaded with minimum amount of memory and
seems is able to handle any amount of data without any issues.<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>When I use Netty&#8217;s HexDumpProxy example as my proxy
server (slightly modified to toggle throttling) to connect to the TestServer, I
experience the OOM rather quickly. &nbsp;I &nbsp;and using the same TestClient
app, simply adjusted to connect through the proxy instead of direct.&nbsp; A
timer has been set up in the HexDumpProxy to display the memory usage
information to the console every 5 seconds, which displays the memory usage growing
out of control.&nbsp; I&#8217;m guessing this is due to the messages queuing up
faster than the client can read them.&nbsp; However, even after adding
throttling to the HexDumpProxyInboundHandler to suspend the reading when the
inboundChannel is not writeable, the proxy still runs out of memory.&nbsp;<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>Netty Versions:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
tested both <b>netty-3.1.5.GA.jar </b>and <b>netty-3.2.1.Final.jar</b><o:p></o:p></p>

<p class=MsoNormal>Java
Version:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
JDK 1.6.0_13<o:p></o:p></p>

<p class=MsoNormal>JRE
Memory:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
128MB max (-Xmx128M)<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>Because of this, I am currently stuck with using OIO, but need
to use NIO for scalability reasons.&nbsp; I am wondering if this is a bug in
Netty, and if so, should I open an issue?&nbsp; Please let me know where I can send
the example code.<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>Kind regards,<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal><span style='font-size:12.0pt'>E R I C K&nbsp;&nbsp; L I C H
T A S<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:12.0pt;color:green'>Linoma Software<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;color:green'>p. 402.944.4242
x714<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;color:green'>f. 402.944.4243<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt'><a
href="http://www.linomasoftware.com/"><span style='color:blue'>www.LinomaSoftware.com</span></a><o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt'><a
href="http://www.goanywheremft.com/"><span style='color:blue'>www.GoAnywhereMFT.com</span></a><o:p></o:p></span></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

</body>

</html>