Java process ignores the soft limit of "open files" (file descriptor) setting for the user and it increases to the hard limit

Solution Verified - Updated -

Issue

Java process ignores the soft limit of "open files" (file descriptor) setting for the user and it increases to the hard limit. So, its "max file descriptor" is different from the result of "ulimit -n" of the user.

For example, "file descriptor (open files)" for the user of Java process is set to 1024 as shown below:

$ 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) 10761
max locked memory       (kbytes, -l) 64
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) 10761
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

However, cat /proc/$JAVA_PID/limits shows the different value 4096 for "Max open files" as shown below:

$ cat /proc/2797/limits
Limit                     Soft Limit           Hard Limit           Units
Max cpu time              unlimited            unlimited            seconds
Max file size             unlimited            unlimited            bytes
Max data size             unlimited            unlimited            bytes
Max stack size            10485760             unlimited            bytes
Max core file size        0                    unlimited            bytes
Max resident set          unlimited            unlimited            bytes
Max processes             10761                10761                processes
Max open files            4096                 4096                 files
Max locked memory         65536                65536                bytes
Max address space         unlimited            unlimited            bytes
Max file locks            unlimited            unlimited            locks
Max pending signals       10761                10761                signals
Max msgqueue size         819200               819200               bytes
Max nice priority         0                    0
Max realtime priority     0                    0
Max realtime timeout      unlimited            unlimited            us

What causes this? Is this expected behavior?

Environment

  • Java
  • Linux

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content