Search code examples
memory-leaksdebianout-of-memoryshhtop

Debian: Cannot fork (Memory Issue)


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


Solution

  • 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.