The direct buffers are handled differently in the JVM, there is a
parameter to tune how big the space is (-XX:MaxDirectMemorySize=XYZm).
In 1.5 it was a fixed size and I think in 1.6 it was changed to be a
percentage of the heap size.    From my experience when you use the heap
buffers they get GCed just like any other object fairly quickly since
they are short lived objects.  

 

Our program uses 10-15k connections going at the same time (10 with the
added overhead of SSL).  With direct buffers the JVM just used too much
memory..

 

-Scott

 

________________________________

From: Scott Carter [mailto:[EMAIL PROTECTED]
Sent: Sat 10/20/2007 9:07 PM
To: [email protected]
Subject: RE: Out of Memory issues with our mina proxy

Thanks for the response.  Can you explain how using heap buffers fixes
the issue?  Seems that they would still use a memory foot print.  Are
they just garbage collected differently?  Did this change fix the issue
for you?

-----Original Message-----
From: Scott Peters [mailto:[EMAIL PROTECTED]
Sent: Saturday, October 20, 2007 7:02 PM
To: [email protected]
Subject: RE: Out of Memory issues with our mina proxy

I have run into similar issues with out of memory problems and moved the
code to use heap buffers instead of direct buffers.



See this page.

http://mina.apache.org/faq.html#FAQ-Iget%7B%7BOutOfMemoryError%7D%7Dorre
sponsetimeoutandconnectionresetunderheavyload.



If you use the SSL filter is not controlled in the same way and you need
to set an environment variable either at the java start line or
programmatically by:

System.setProperty("mina.sslfilter.directbuffer", "false");



Hope that helps,

Scott





________________________________

From: Scott Carter [mailto:[EMAIL PROTECTED]
Sent: Saturday, October 20, 2007 4:08 PM
To: [email protected]
Subject: Out of Memory issues with our mina proxy



We have written a server proxy layer using the mina library, and
everything works as it should except we are running into "Out of Memory"
exceptions.  We did the obvious things such as increasing the memory for
the proxy and still always had the same issue (just took a little longer
to produce it).  We analyzed the application with a profiler and
discovered that a thread from mina was creating LinkedBlockingQueue$Node
objects that were not being garbage collected.  I read a couple of
previous posts on the issue and could not find a good solution.  Based
on the posts I did verify that these objects were not being garbage
collected even after the server had been idol for a long time and all
sessions had been closed. 



Our proxy binds to the outside port of a version control server and
passes data back and fourth between clients and the version control
server.  I have attached our code, which is pretty simple, to this post.
You can see that we have some methods that take a few bites off of the
messages and verify the client for us, but other than that this is just
a very straight forward proxy application. 



I really need some help to figure out how to get the
LinkedBlockingQueue$Node objects garbage collected.  I have posted below
the stack trace that creates the LinkedBlockingQueue$Node objects from
the mina thread:



TRACE 319549: (thread=200037)


java.util.concurrent.LinkedBlockingQueue$Node.<init>(LinkedBlockingQueue
.java:70)


java.util.concurrent.LinkedBlockingQueue.insert(LinkedBlockingQueue.java
:129)


java.util.concurrent.LinkedBlockingQueue.offer(LinkedBlockingQueue.java:
335)


java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:
653)


org.apache.mina.filter.executor.ExecutorFilter.fireEvent(ExecutorFilter.
java:101)


org.apache.mina.filter.executor.ExecutorFilter.messageSent(ExecutorFilte
r.java:214)


org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageSent
(AbstractIoFilterChain.java:320)


org.apache.mina.common.support.AbstractIoFilterChain.access$1200(Abstrac
tIoFilterChain.java:53)


org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.message
Sent(AbstractIoFilterChain.java:652)


org.apache.mina.common.support.AbstractIoFilterChain$HeadFilter.messageS
ent(AbstractIoFilterChain.java:503)


org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageSent
(AbstractIoFilterChain.java:320)


org.apache.mina.common.support.AbstractIoFilterChain.fireMessageSent(Abs
tractIoFilterChain.java:314)


org.apache.mina.transport.socket.nio.SocketIoProcessor.doFlush(SocketIoP
rocessor.java:358)


org.apache.mina.transport.socket.nio.SocketIoProcessor.doFlush(SocketIoP
rocessor.java:314)


org.apache.mina.transport.socket.nio.SocketIoProcessor.access$600(Socket
IoProcessor.java:44)


org.apache.mina.transport.socket.nio.SocketIoProcessor$Worker.run(Socket
IoProcessor.java:431)


org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.j
ava:39)

        java.lang.Thread.run(Thread.java:619)





Thank you in advance for helping a Newbie.  This is a production
application that I need to get working ASAP.  Thanks - Scott

Conexant E-mail Firewall (Conexant.Com) made the following annotations
---------------------------------------------------------------------
********************** Legal Disclaimer ****************************
"This email may contain confidential and privileged material for the
sole use of the intended recipient. Any unauthorized review, use or
distribution by others is strictly prohibited. If you have received the
message in error, please advise the sender by reply email and delete the
message. Thank you."
**********************************************************************
---------------------------------------------------------------------

Reply via email to