6

Tomcat runs on my workstation for several days, now it has no response, lsof command outputs lots of close_wait state connections, tomcat pid is 25422, however the ulimit command shows that the "open file" is 1024, how can this happen?

[root@localhost home]# lsof -p 25422 | wc -l
10309

[root@localhost home]# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 399360
max locked memory       (kbytes, -l) 32
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 399360
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
2

3 Answers 3

1

For open files, we have soft / hard open files limit on linux os.

If the soft limit is reached, it will just expand the limit to higher limit but under Hard limit.

By checking the hard limit, you can simply run:

# ulimit -Hn

Here is also an article that may help you understand more:

Guide to limits.conf / ulimit /open file descriptors under linux

1

Not every type of entry in lso counts towards ulimit. RUn the following command for getting only those fds that count towards ulimit

lsof -p <pid> -d '^cwd,^err,^ltx,^mem,^mmap,^pd,^rtd,^txt' -a
0
  1. Lsof Options in Linux man page describes the command as follows:

In the absence of any options, lsof lists all open files belonging to all active processes.

enter link description here

  1. Ulimit simply limits resources at the user level,and applied to each process .That's why you see that the number in the Lsof report is far greater than that of the ulimit.

  2. If you want to get kernel level restrictions, use the following command

cat /proc/sys/fs/file-max

You'll get a very big number.

In summary, lsof may be more than ulimit , and it is definitely less than file-max.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.