0

Recently my processes started to randomly die with an out of memory exception. Furthermore the restart script for those processes printed: ./start.sh: 4: ./start.sh: Cannot fork

The script looks like this:

#!/bin/sh

#EU1
while :
do

if ! screen -list | grep -q "eu1"; then
echo EU1 ist down, Patch eingeleitet!
cd MysticRunes/EU1
./patch.sh
echo EU1 Patch ausgeführt!
screen -dmS eu1 java -Xms6000M -Xmx6000M -jar spigot.jar nogui
echo EU1 neugstartet!
cd ../..
fi

#MRDev
if ! screen -list | grep -q "mrdev"; then
echo MRDev ist down, restart eingeleitet!
cd MysticRunes/Developer
screen -dmS mrdev java -Xms4000M -Xmx4000M -jar spigot.jar nogui
echo MRDev neugstartet.
cd ../..
fi

sleep 1
done

free -m shows this:

             total       used       free     shared    buffers     cached
Mem:         32125      29902       2222          0       1386      17873
-/+ buffers/cache:      10642      21483
Swap:        16375          0      16375

And htop shows this: htop screenshot

I can't really tell whats the issue here. I have looked up the memory being used issue and afaik my memory is used that much at all because it is only caching stuff and memory allocated to the cache is supposed to be free when the server is in need of more memory. HTOP showing the same process over and over again is probably only the amount of threads the server is running right? So basicly all the entries with 8.7% memory usages of the process can be combined to a total of 8.7% too?

Maybe I am just getting this wrong so please correct and/or help me.

Sincerely, Jalau

Jalau
  • 303
  • 1
  • 2
  • 11
  • Is the number of threads normal for this Java application? The application may be creating threads non-stop (due to a bug or misconfiguration) and causing the kernel's process table to fill up to a point it cannot create new PIDs. If you're running 32bit Linux your /proc/sys/kernel/pid_max may be as low as 32768. – Hisham H M Mar 16 '17 at 00:42
  • @HishamHM I think it should be normal. I can check however. Thanks for the tip. How can I check for Linux 32bit? What should I do if that is the case? – Jalau Mar 16 '17 at 17:48
  • Run `cat /proc/sys/kernel/pid_max` and see the number it returns. If it's a low number like 32768, you won't be able to have more than this number of threads. Running `ps -efL | wc -l` will give you the current number of PIDs in use. – Hisham H M Mar 18 '17 at 02:47

1 Answers1

1

The solution was that there was a thread pool that kept creating threads and thus causing the max amount of threads to be reached at some point. Thanks for helping.

Jalau
  • 303
  • 1
  • 2
  • 11