Home:ALL Converter>Unix doman socket descriptor leak in java program

Unix doman socket descriptor leak in java program

Ask Time:2020-02-20T13:04:01         Author:Wei Zhao

Json Formatter

I have a java program which suffer from file descriptor leak.

lsof -p <PID> -nP shows a huge number of items that point to the same inode. Here is an example of the list:

java    16352 myprogram  354u     unix 0xffff88042805e800      0t0 1755895875 type=STREAM
java    16352 myprogram  355u     unix 0xffff88042805e800      0t0 1755895875 type=STREAM
java    16352 myprogram  356u     unix 0xffff88042805e800      0t0 1755895875 type=STREAM

then i used netstat -ano, and it shows that the Inode points to an active unix domain socket. here is the list:

Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node Path
unix  2      [ ACC ]     STREAM     LISTENING     1755939110 /tmp/.java_pid16352.tmp
unix  2      [ ]         STREAM     CONNECTED     1755871862 
unix  2      [ ]         STREAM     CONNECTED     1755895875

here is the info provided by /proc/16352/net/unix:

Num       RefCount Protocol Flags    Type St Inode Path
ffff8803d0181400: 00000002 00000000 00010000 0001 01 1755939110 /tmp/.java_pid16352.tmp
ffff880426541400: 00000002 00000000 00000000 0001 03 1755871862
ffff88042805e800: 00000002 00000000 00000000 0001 03 1755895875

I tried the methods to find out the other end of the unix domain socket (https://unix.stackexchange.com/questions/16300/whos-got-the-other-end-of-this-unix-socketpair/190606#190606) , but lsof +E -aUc Xorg provided nothing; ss -xp | grep 1755895875 also provided nothing.(i don't understand what's the mean of "The sockets are identified by their inode number. Note that it's not related to the filesystem inode of the socket file." in Stéphane Chazelas's answer)

please help me finding a way to figure out:

  1. which thread in my java process continuously generated those unix doman socket descriptors and lead to the file descriptor leak issue.
  2. how can I find out the other endpoint of the unix domain socket.

Author:Wei Zhao,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/60313210/unix-doman-socket-descriptor-leak-in-java-program
yy