0

I have the following problem: I have an Kotlin host application that start another Java programm with

 val process = ProcessBuilder(*split("java -jar second.jar").toTypedArray())
            .directory(File(this.directory))
            .redirectErrorStream(true)
            .start();

On machine (PopOs 20.04, 16GB Ram) this works fine, but if I run it on the sever (Debian stretch, 8GB Ram ) the second.jar program throws a "java.lang.OutOfMemoryError: unable to create native thread: possibly out of memory or process/resource limits reached" exception.

Any ideas how I could fix it?

Tetraowl
  • 3
  • 2
  • 2
    take a thread dump and analyse – Hussain Akhtar Wahid 'Ghouri' Sep 26 '20 at 22:49
  • The error suggests you've hit one of the OS-level limits related to the [maximum number of threads](https://stackoverflow.com/questions/344203/maximum-number-of-threads-per-process-in-linux) or memory mappings. Check `ulimit -u`, `sysctl kernel.pid_max`, `sysctl kernel.threads-max`, `sysctl vm.max_map_count`. – apangin Sep 28 '20 at 09:58
  • Meanwhile I have the problem on the whole server. But I am a bit helpless, because `ulimit -u` returns 62987 but tp just shows ~200 threads. sysctl kernel.pid_max = 4194304; sysctl kernel.threads-max = 3090195; sysctl vm.max_map_count = 65530 – Tetraowl Sep 28 '20 at 18:18

0 Answers0