java程序中的文件描述符泄漏:打开的文件太多 [英] file descriptor leak in java program : too many open files

查看:580
本文介绍了java程序中的文件描述符泄漏:打开的文件太多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文件描述符增加的程序。
我看到当我执行命令ls -l / proc / 5969 / fd时,其中5969是java程序的pid文件描述符的个数不断增加。
,但是我无法打开其中一个文件描述符来查看哪个文件保持打开状态:
这里是一个列表示例:

  lrwx ------ 1 root root 64 oct 24 16:08 52295  - > socket:[2577706264] 
lrwx ------ 1 root root 64 oct 24 16:08 52296 - > socket:[2579543392]
lrwx ------ 1 root root 64 oct 24 16:08 52297 - > socket:[2578760962]

请帮我找一个方法来解决这个文件描述符泄漏知道什么文件保持开放并增加文件描述符数量。


解决方案

好了,从一个快速的观察,您使用的插座文件描述符,不文件



在UNIX中,文件和套接字都使用文件描述符,所以在打开套接字时没有问题。 b

因此,您不会打开一个文件,但实际上将端口号从其他程序中禁用。


I have a program which suffer from file descriptor increasing. I see when I execute the command ls -l /proc/5969/fd where 5969 is the pid of the java program the number of file descriptor continuously increasing. but I am unable to open one of those files decriptors to see what file remains open : here is an example of the listing :

lrwx------ 1 root root 64 oct 24 16:08 52295 -> socket:[2577706264]
lrwx------ 1 root root 64 oct 24 16:08 52296 -> socket:[2579543392]
lrwx------ 1 root root 64 oct 24 16:08 52297 -> socket:[2578760962]

Please help me finding a way to solve this file descriptor leak in knowing what files remains open and increase the file descriptor number.

解决方案

Well, from a quick observation, you are using file descriptors on sockets, not files

In UNIX, both files and sockets use file descriptors, and so you have a problem where you are not closing sockets that you open.

As a result, you are not leaving a file open but are actually leaving port numbers locked from use by other programs.

这篇关于java程序中的文件描述符泄漏:打开的文件太多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆