java - Too many open files error but lsof shows a legal number of open files -



java - Too many open files error but lsof shows a legal number of open files -

my java programme failing with

caused by: java.io.ioexception: many open files @ java.io.unixfilesystem.createfileexclusively(native method) @ java.io.file.createnewfile(file.java:883)...

here key lines /etc/security/limits.conf. set max files user @ 500k:

root soft nofile 500000 root hard nofile 500000 * soft nofile 500000 * hard nofile 500000

i ran lsof to count number of files open -- both globally , jvm process. examined counters in /proc/sys/fs. seems ok. process has 4301 files open , limit 500k:

:~# lsof | wc -l 5526 :~# lsof -uusername | wc -l 4301 :~# cat /proc/sys/fs/file-max 744363 :~# cat /proc/sys/fs/file-max 744363 :~# cat /proc/sys/fs/file-nr 4736 0 744363

this ubuntu 11.04 server. have rebooted positive these parameters beingness used.

i don't know if it's relevant, process started upstart script, starts process using setuidgid, this:

exec setuidgid username java $java_opts -jar myprogram.jar

what missing?

it turns out problem programme running upstart init script, , exec stanza not invoke shell. ulimit , settings in limits.conf apply user processes in shell.

i verified changing exec stanza to

exec sudo -u username java $java_opts -jar program.jar

which runs java in username's default shell. allowed programme utilize many open files needs.

i have seen mentioned can phone call ulimit -n prior invoking command; upstart script think utilize script stanza instead.

i found improve diagnostic lsof ls /proc/{pid}/fd | wc -l, obtain precise count of open file descriptor. monitoring see failures occurred right @ 4096 open fds. don't know 4096 comes from; it's not in /etc anywhere; guess it's compiled kernel.

java linux

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -