简体   繁体   中英

file descriptor leak in java program : too many open files

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.

Try

# lsof -p <pid>

will list all 'files' open by process id, may show you the ip/port the socket was bound to. If your program is client side, youre probably getting disconnected by TCP RST and not cleaning up the file descriptor properly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM