{"id":2975,"date":"2023-02-05T15:19:38","date_gmt":"2023-02-05T14:19:38","guid":{"rendered":"https:\/\/bob-team.de\/wordpress\/?p=2975"},"modified":"2023-02-05T15:19:38","modified_gmt":"2023-02-05T14:19:38","slug":"linux-java-outofmemmory","status":"publish","type":"post","link":"https:\/\/bob-team.de\/wordpress\/2023\/02\/05\/linux-java-outofmemmory\/","title":{"rendered":"Linux\/Java OutOfMemmory"},"content":{"rendered":"<p><strong>max user processes<\/strong><\/p>\n<p>You are reaching the threads limit, for the user, process, or an overall limit<\/p>\n<p>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<\/p>\n<p>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<\/p>\n<p><code>ulimit -a <\/code><\/p>\n<p>You can see how many threads are running using this command<\/p>\n<p><code>$ ps -elfT | wc -l<\/code><\/p>\n<p>To get how many threads your process is running (you can get your process pid using top or ps aux):<\/p>\n<p><code>$ ps -p <PROCESS_PID> -lfT | wc -l<\/code><\/p>\n<p>The \/proc\/sys\/kernel\/threads-max file provides a system-wide limit for the number of threads. The root user can change that value<\/p>\n<p>To change the limits (in this case to 4096 threads):<\/p>\n<p><code>$ ulimit -u 4096 <\/code><\/p>\n<p><a href=\"http:\/\/www.mastertheboss.com\/jboss-server\/jboss-monitoring\/how-to-solve-javalangoutofmemoryerror-unable-to-create-new-native-thread\">weiterlesen&#8230;<\/a><\/p>\n<p><strong>java app with system.d<\/strong><\/p>\n<p>I recently stumbled over <a href=\"https:\/\/www.freedesktop.org\/software\/systemd\/man\/systemd-system.conf.html\">DefaultTasksMax<\/a> which for some reason was limited to 60 on my machine &#8211; not enough for my new keycloak installation.<\/p>\n<p>Keycloak crashes with java.lang.OutOfMemoryError : unable to create new native Thread as soon as it hits the &#8217;60&#8216; limit (<code>ps -elfT | grep keycloak|wc -l<\/code>).<\/p>\n<p><em>1. Look up your system.d settings<\/em><\/p>\n<p><code>systemctl show --property DefaultTasksMax<\/code><\/p>\n<p>In my case. This printed 60<\/p>\n<p><em>2. Provide a higher value<\/em><\/p>\n<p><code>editor \/etc\/systemd\/system.conf<\/code><\/p>\n<p>Edit:<\/p>\n<p>DefaultTasksMax=128<br \/>\nYou can also set a similar value <a href=\"https:\/\/www.freedesktop.org\/software\/systemd\/man\/systemd.resource-control.html\">TaskMax in your Unit-File<\/a>.<\/p>\n<p><em>3. Reload, Check, Restart<\/em><\/p>\n<p><code>systemctl daemon-reload<br \/>\nsystemctl show --property DefaultTasksMax<br \/>\nsystemctl start keycloak<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2975","post","type-post","status-publish","format-standard","hentry","category-uncategorized","entry"],"_links":{"self":[{"href":"https:\/\/bob-team.de\/wordpress\/wp-json\/wp\/v2\/posts\/2975","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bob-team.de\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bob-team.de\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bob-team.de\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bob-team.de\/wordpress\/wp-json\/wp\/v2\/comments?post=2975"}],"version-history":[{"count":2,"href":"https:\/\/bob-team.de\/wordpress\/wp-json\/wp\/v2\/posts\/2975\/revisions"}],"predecessor-version":[{"id":2977,"href":"https:\/\/bob-team.de\/wordpress\/wp-json\/wp\/v2\/posts\/2975\/revisions\/2977"}],"wp:attachment":[{"href":"https:\/\/bob-team.de\/wordpress\/wp-json\/wp\/v2\/media?parent=2975"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bob-team.de\/wordpress\/wp-json\/wp\/v2\/categories?post=2975"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bob-team.de\/wordpress\/wp-json\/wp\/v2\/tags?post=2975"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}