Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 11-23-2017, 08:19 PM   #1
LQ Newbie
Registered: Nov 2017
Posts: 2

Rep: Reputation: Disabled
bash: fork: retry: Resource temporarily unavailable - Limit issue?

I've looked through the other posts and feel like this question has been answered and doesn't apply to my situation or was asked and the thread has gone stale.

Ubuntu OS 16.04. Running Java Process.
java -version
openjdk version "1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-0ubuntu0.16.04.2-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)
(not that it matters because I'm running into other limit issues I believe. Doesn't look like anything to do with java HEAP Xms Xmx Xss type stuff. )

I'm running a process that uses many threads i want 10,000's of threads potentially.
My process stops making threads around 12,000, I'm very confused about this. (the same exact number every time)

When it ramps up to ~12,000 threads I will also have issues running commands in the shell

my normal user: (while process is running)
-bash: fork: retry: Resource temporarily unavailable
-bash: fork: retry: Resource temporarily unavailable
-bash: fork: retry: Resource temporarily unavailable
-bash: fork: retry: Resource temporarily unavailable
-bash: fork: Resource temporarily unavailable
as root: (while process is running)
-bash: fork: retry: No child processes
(so makes me think this is a system wide thing? not a specific user issue? since both root and my normal user have shell issues)

Here's some information which might be able to help. I'm confused on what limit I'm hitting exactly.

`free -m`
              total        used        free      shared  buff/cache   available
Mem:          60395         306       59195           8         892       59349
Swap:             0           0           0
`ulimit -a`
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 241522
max locked memory       (kbytes, -l) unlimited
max memory size         (kbytes, -m) unlimited
open files                      (-n) 500000
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 256
cpu time               (seconds, -t) unlimited
max user processes              (-u) 1000000
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
(I've messed with stack size making it 600,000 to 256 doesn't seem to affect anything)

`sysctl kernel.pid_max`
kernel.pid_max = 4194303
`cat /proc/sys/kernel/threads-max`
`cat /proc/sys/fs/file-nr`
832	0	6168013
ps -T -p <pid>
(will give me how many threads are being used which stops around 12000)

I don't see anything interesting in /var/log/syslog

So, what the heck is going on exactly. What limit am I hitting? I don't feel like I'm hitting a process count limit as the ulimit -a results show the limit is very high.. the thread max count is very high. Feeling a little confused here.

Tried this java application out on multiple cloud hardware configurations.. all yielding the same result. from 1cpu - 6gb of ram to 16cpu - 60gb of ram and several hardware configs in between.

Figured out the issue

/etc/systemd/logind.conf UserTasksMax needs to be set higher than ~12000
Not sure how this is read in, but a reboot of the server activated this number

I think it's also worth noting that
Could probably be limitations if I was trying to go much higher with thread count, and these might be my next limiters if I decided to go bigger with thread count.

Instead of rebooting you can do these commands
sudo systemctl daemon-reload
sudo systemctl daemon-reexec
sudo service systemd-logind restart
Then restart your shell or.. exit.. and ssh back in

Last edited by miketwenty1; 11-24-2017 at 06:20 PM. Reason: additional information
Old 11-25-2017, 03:32 AM   #2
LQ Addict
Registered: Dec 2013
Posts: 17,250
Blog Entries: 10

Rep: Reputation: 5160Reputation: 5160Reputation: 5160Reputation: 5160Reputation: 5160Reputation: 5160Reputation: 5160Reputation: 5160Reputation: 5160Reputation: 5160Reputation: 5160
thanks for posting your solution.
if you edit your post, it will not show up as a new post in other member's feeds, and it can also seriously disrupt the flow of communication.
it would've been better to post the solution as a separate post/reply.
that way your thread also loses zero reply status.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
-bash: fork: retry: Resource temporarily unavailable urello Linux - General 3 12-15-2015 06:24 AM
[SOLVED] "bash: fork: Resource temporarily unavailable" now occurring, did not before RandomTroll Linux - Software 3 04-18-2013 07:56 PM
Default bash: fork: Resource temporarily unavailable :SSH LittleMaster Linux - Server 3 03-13-2013 09:32 PM
fork: resource temporarily unavailable ??? str8edge Linux - General 3 06-21-2011 09:00 AM
./configure: fork: Resource temporarily unavailable doodlebug Linux - Server 3 08-23-2007 03:34 PM > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:07 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration