Skip to main content

Eclipse - Too many open files Problem

· 3 min read

If your OS is Linux and you are using Eclipse, you might possibly see the following error messages or similar after installing lots of plug-ins in Eclipse. In my case, it usually happened after installing TPTP (I'm using Ubuntu Linux 9.04 Jaunty Jackalope Desktop 64bit by the way).

Plug-in org.eclipse.jst.server.tomcat.core was unable to load class org.eclipse.jst.server.tomcat.core.internal.TomcatLaunchConfigurationDelegate. /eclipse_installed_path/eclipse/configuration/org.eclipse.osgi/.lazy.15 (Too many open files)

or

Problems occurred while trying to save the state of the workbench. Could not read master table. /your_workspace/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources (Too many open files)

or

java.util.zip.ZipException: error in opening zip file

This is because there are too many files opened and these are more files than the number of open files allowed . So Eclipse cannot open more files and displays the errors above.

Let's see the number of open files.

$ lsof | wc -l

e.g.)

$ lsof | wc -l 8965

In my case, it was 8965.

What about the number of files Eclipse opens. To see it, use

$ lsof | grep eclipse | wc -l

In my case,

$ lsof | grep eclipse | wc -l 2094

2094 files are opened.

Now check the limitation of open files

$ ulimit -a
core file size (blocks, -c) #
data seg size (kbytes, -d) #
scheduling priority (-e) #
file size (blocks, -f) #
pending signals (-i) #
max locked memory (kbytes, -l) #
max memory size (kbytes, -m) #
open files (-n)
1024 pipe size (512 bytes, -p) #
POSIX message queues (bytes, -q) #
real-time priority (-r) #
stack size (kbytes, -s) #
cpu time (seconds, -t) #
max user processes (-u) #
virtual memory (kbytes, -v) #
file locks (-x) #

or just use

$ ulimit -n
1024

To change it, open the file /etc/security/limits.conf and put a greater number than 1024 depending on the number of open files you checked with lsof | wc -l just before.
For example, Open the file

$ gksudo gedit /etc/security/limits.conf

add these lines

*                soft    nofile          9216
* hard nofile 9216

I just chose some big number that is 9216 (9 * 1024) as it's greater than 8965

Log out and in then check with ulimit. It should show like this.

$ ulimit -n 9216 

You may try this

$ ulimit -n 9216 

yet I don't believe it changes the limit for open files permanently. So you'd better modify /etc/security/limits.conf file.

If it is still not changed. Restart the computer and check again. If it still doesn't show the changed value, open /etc/pam.d/common-session file and add session required pam_limits.so.

Open the file to edit

$ gksudo gedit /etc/pam.d/common-session

Add the following line
session required pam_limits.so

Log out and in. Now it should work!
$ ulimit -n
9216