Search code examples
javalinux

Error upon jar execution - unable to allocate file descriptor table


Upon trying to use a jar on the local linux machine, I am getting the following error: library initialization failed - unable to allocate file descriptor table - out of memory

The machine has 32G RAM

I can provide additional information, if needed.

Any help would be appreciated.


Solution

  • In recent versions of Linux default limit for the number of open files has been increased significantly. Java 8 does the wrong thing of trying to allocate memory upfront for this number of file descriptors (see https://bugs.openjdk.java.net/browse/JDK-8150460). Previously this worked, when the default limit was much lower, but now it tries to allocate too much and fails. Workaround for this is to set a lower limit of number of open files (or use newer java):

    $ mvn
    library initialization failed - unable to allocate file descriptor table - out of memoryAborted
    $ ulimit -n 10000
    $ mvn
    [INFO] Scanning for projects...
    ...