[ 
https://issues.apache.org/jira/browse/DIRMINA-789?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12877907#action_12877907
 ] 

Sai Pullabhotla commented on DIRMINA-789:
-----------------------------------------

Not to criticize or blame any one, but is the JavaDoc for IoSession.write(), is 
not accurate? It clearly states that - 

/**
Writes the specified message to remote peer. This operation is asynchronous; 
IoHandler.messageSent(IoSession, Object) will be invoked when the message is 
actually sent to remote peer. You can also wait for the returned WriteFuture if 
you want to wait for the message actually written.
**/

As you can see it clearly states that the message is written to the remote 
peer, not to the IoProcessor queue. So, according to this doc, waiting on the 
Furture should be sufficient. If not, we need to update the documentation. 

Also, the doc gives me the impression that one call to 
session.write(<something>) would result in one and only one "messageSent" event 
with the very same message that was written, assuming that the write was 
successful. I do understand that at the TCP level, the data might have been 
broken down into several packets, but messageSent should be fired only once, 
after all packets are sent. 

This is my interpretation of the doc (and the behavior one would naturally 
expect), and it contradicts with what you have said, where one call to 
session.write might result in an unknown number of messageSent events. At 
least, I hope that's what you said. If not, please correct me understand it. 

Now coming back to my original requirement - 

Client (C), connects to Server 1 (S1) and Server 2 (S2). Let's say S1 is a web 
server like Apache or App Server like Tomcat. S1 is sending a large file back 
to C. C has to forward that to S2. S1 is sending data as fast as it can, and C 
is receiving the messageReceived events. As soon as it sees this event, I 
simply writes the message to S2 (and possibly wait for the Future to complete, 
which does not guarantee a successful write?).  Transfer rate from C to S2 is a 
lot slower than what it is from S1 to C. So, how can I prevent OOM in this 
scenario? Do I've to use some kind of locks/synchronization based on how many 
bytes were received vs. sent? 


> Possible Deadlock/Out of memory when sending large amounts of data using Nio
> ----------------------------------------------------------------------------
>
>                 Key: DIRMINA-789
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-789
>             Project: MINA
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0.0-RC1
>         Environment: Windows Vista 64-bit Java 5 and Java 6
>            Reporter: Sai Pullabhotla
>         Attachments: MinaClient.java, RandomDataServer.java
>
>
> This is a followup to the post on the DEV mailing list, 
> http://old.nabble.com/Help-needed-with-OutOfMemory-error-and-or-GC-Issues-Dead-Locks-td28849756.html.
>  
> I've even simplified the test cases so now it just has one simple NioServer, 
> and an NioClient. The MinaClient class creates 5 concurrent connections to 
> the RandomDataServer. Upon a successful connection, the server is setup to 
> send 500MB worth of random text data. The MinaClient just saves the received 
> data to a temp file in the working directory. When I run this code with small 
> amounts of data, it works fine, but with 500MB, I did not have success yet. 
> Some times, I get OOM on the server. Some times, nothing happens. 
> I've declared several constants in each class that you could change to try 
> various settings such as changing the amount of data served by the server, 
> whether or not to use an executor filter/IoEventThrottle etc. 
> Both classes have main methods, and I was running them as stand alone 
> applications on the same PC. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to