Eclipse – “Too many open files” Problem

来源:互联网 发布:蚂蚁金服 java 工资 编辑:程序博客网 时间:2024/06/10 14:51


1.问题

在开发的时候遇见这个问题,总是提示Too many open files。日志如下:

Errors occurred during the build.
Errors running builder 'Android Pre Compiler' on project 'binkery-demo'.
Errors occurred while refreshing resources with the local file system.
Could not write metadata for '/home/binkery/workspace/.metadata/.plugins/org.eclipse.core.resources/.projects/binkery-demo/.indexes/properties.index'.
/home/binkery/workspace/.metadata/.plugins/org.eclipse.core.resources/.projects/binkery-demo/.indexes/properties.index (Too many open files)
Errors occurred while refreshing resources with the local file system.
Could not write metadata for '/home/binkery/workspace/.metadata/.plugins/org.eclipse.core.resources/.projects/binkery-demo/.indexes/properties.index'.
/home/binkery/workspace/.metadata/.plugins/org.eclipse.core.resources/.projects/binkery-demo/.indexes/properties.index (Too many open files)

2.解释:

在网上找了一下,貌似跟ubuntu下个配置有关。老外是这么说的:
Eclipse – “Too many open files” Problem
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).

3.发现

打开命令行终端,
$lsof | wc -l
这个命令能打印出当前打开的文件数目。我的打印出来是5000+
$lsof | grep eclipse | wc -l
这个命令打印出eclipse打开的文件数目。我的打印出来是有500+。
$ulimit -n
直接打印出来一个1024。这个1024应该是你当前电脑上的配置的数目。
这个时候需要修改这个数目,让它大一点。

4.解决

老外这么说的:
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.

$ gksudo gedit /etc/security/limits.conf
add these lines
*                soft    nofile          9216
*                hard    nofile          9216
把这两行加进去。注意要有前面的*号。
sudo vi /etc/security/limits.conf也可以
然后注销一下重新登录进来看一下
$ulimit -n
这个时候应该是9216了。

转载http://www.binkery.com/post.php?p=179


原创粉丝点击