Too many open files error with Netty

Albert Strasheim fullung at gmail.com
Thu Oct 15 08:08:48 EDT 2009


Hello again

On Wed, Oct 14, 2009 at 12:46 PM, Albert Strasheim <fullung at gmail.com> wrote:
> I'm a new Netty user and I'm having some problems with a "Too many
> open files" error.
> I'm doing some tests with a server based on the Discard example:
> Then it starts connecting clients, each of which writes some data and
> then closes the connection.
> The main thread runs a loop that keeps 15000 client connections alive.
> I'm using Netty 3.1.5 on Solaris 10 with JDK 1.6.0_16.

I've done some further analysis.

First I attached to the process with Visual VM. I noticed that the
used heap kept growing steadily.

After about 45000 connections, I did a heap dump using jmap and then
analyzed the dump with Eclipse Memory Analyzer.

I can see 45000 live NioClientSocketChannel instances, when I would
expect to see only 15000 (one for each active connection).

I did a "Merge Shortest Paths to GC Roots" with all references to these objects.

It seems they are being kept alive by a HashMap called fdToKey which
is a field of a class called sun.nio.ch.DevPollSelectorImpl, which I
assume is the selector implementation class being used on Solaris.

Each I/O client worker thread has one of these DevPollSelectorImpl
instances, and each fdToKey HashMap inside that references a few
thousand NioClientSocketChannel instances.

Am I doing something wrong to prevent these NioClientSocketChannels
from being closed properly?

Thanks!

Regards,

Albert


More information about the netty-users mailing list