[ale] "Too many open files" while opening a socket on Ubuntu

JK jknapka at kneuro.net
Thu Mar 5 10:07:38 EST 2009


Greg Freemyer wrote:
> I hit a similar issue 7 or 8 years ago.
> 
> It was a limit in the J2EE stack somewhere.  It was just a config
> variable to fix.


Has to be specific to the Linux port of J2SE, then.  I don't
have any issue like this on XP.

Also weird: I have another Java app that opens 1000 UDP sockets
and binds them with no problem, every time.  This issue seems
to be related to the fact that the process I'm having trouble with
uses the Java Selector API.  lsof reveals that, unlike the code
that works, the broken code opens not only a socket, but also
a pipe and an anonymous inode for every socket. When I rip
out all use of Selectors, this no longer happens and everything
proceeds according to plan -- except the code doesn't work,
'cause I really NEED to select() on these puppies :-(

So now I'm thinking I'm hitting a sysctl or ulimit related
to open pipes or inodes, but I spent hours "find"-ing in
/proc/sys last night without hitting anything that looked
relevant.

This is very frustrating!

-- JK


> Greg
> 
> On 3/4/09, Kenneth Ratliff <lists at noctum.net> wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>>
>> On Mar 4, 2009, at 9:58 PM, JK wrote:
>>
>>> I have a Java app that needs to open many many UDP sockets.  When
>>> it's opened around 120 of them, further attempts fail with a
>>> "Too many open files" exception.  It also starts a thread to handle
>>> traffic on each of these sockets.  This error happens on Ubuntu 8.10,
>>> but not on Fedora 8.
>>>
>>> ulimit -a says both max user processes and max open files = 65000
>>> (because I changed them in /etc/security/limits.conf). I mention
>>> user processes because I know Linux threads are implemented as
>>> kernel-level processes, so I thought that might be relevant.
>>>
>>> Any ideas?  Google is leading me only to answers related to
>>> ulimits.  It certainly seems to be a configuration issue with user
>>> resource limits, but I don't see any obvious way to change (or
>>> discover the values of) limits related to sockets.
>>>
>>> I'd really hate to have to go back to Fedora to solve this :-(
>> Check any relevant scripts. I've seen a few cases of this where the
>> script changed the ulimit parameters, which resulted in too many open
>> files. Drove me bat<bleep> insane.
>>
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v2.0.9 (Darwin)
>>
>> iEYEARECAAYFAkmvRjAACgkQXzanDlV0VY70SQCbBE+vbuqqIhz+nzI4tfSungeh
>> Bo0AoMuKmwogMXOYInrd3pnlOopga/PT
>> =Sy9+
>> -----END PGP SIGNATURE-----
>>
>> _______________________________________________
>> Ale mailing list
>> Ale at ale.org
>> http://mail.ale.org/mailman/listinfo/ale
>>
> 


-- 
I do not particularly want to go where the money is -
  it usually does not smell nice there. -- A. Stepanov


More information about the Ale mailing list