Finding hard and soft open file limits from within jvm in linux (ulimit -n and ulimit -Hn)

后端 未结 1 494
生来不讨喜
生来不讨喜 2021-01-06 16:55

I have a problem where I need to find out the hard and soft open file limits for the process in linux from within a java/groovy program. When I execute ulimit from the termi

相关标签:
1条回答
  • 2021-01-06 17:07

    Groovy is setting this limit to maximum in it's start-up scripts.

    In startGroovy:160:

    # Increase the maximum file descriptors if we can.
    if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
        MAX_FD_LIMIT=`ulimit -H -n`
        if [ $? -eq 0 ] ; then
            if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
                MAX_FD="$MAX_FD_LIMIT"
            fi
            ulimit -n $MAX_FD
            if [ $? -ne 0 ] ; then
                warn "Could not set maximum file descriptor limit: $MAX_FD"
            fi
        else
            warn "Could not query businessSystem maximum file 
                  descriptor limit: $MAX_FD_LIMIT"
        fi
    fi
    

    It turns out jvm is setting this limit by itself. I'm not sure why groovy is changing it too. Try:

    java -XX:-MaxFDLimit LinuxInteractor
    

    It will disable this behavior.

    0 讨论(0)
提交回复
热议问题