Linux/Java OutOfMemmory

  • Beitrags-Autor:
  • Beitrags-Kategorie:Sonstiges

max user processes

You are reaching the threads limit, for the user, process, or an overall limit

I had the same problem in a centOS/Red Hat machine. You are reaching the threads limit, for the user, process, or an overall limit

In my case there was a limit on the number of threads a user can have. Which can be checked with, the line saying max user processes

ulimit -a

You can see how many threads are running using this command

$ ps -elfT | wc -l

To get how many threads your process is running (you can get your process pid using top or ps aux):

$ ps -p -lfT | wc -l

The /proc/sys/kernel/threads-max file provides a system-wide limit for the number of threads. The root user can change that value

To change the limits (in this case to 4096 threads):

$ ulimit -u 4096

weiterlesen…

java app with system.d

I recently stumbled over DefaultTasksMax which for some reason was limited to 60 on my machine – not enough for my new keycloak installation.

Keycloak crashes with java.lang.OutOfMemoryError : unable to create new native Thread as soon as it hits the ’60‘ limit (ps -elfT | grep keycloak|wc -l).

1. Look up your system.d settings

systemctl show --property DefaultTasksMax

In my case. This printed 60

2. Provide a higher value

editor /etc/systemd/system.conf

Edit:

DefaultTasksMax=128
You can also set a similar value TaskMax in your Unit-File.

3. Reload, Check, Restart

systemctl daemon-reload
systemctl show --property DefaultTasksMax
systemctl start keycloak