I have installed a Terraria server on my Raspberry Pi (Version B Revision 2) yesterday. I followed this tutorial on Reddit.

I used the latest version of Raspbian provided by NOOBS:

  • I just installed mono-complete instead of just the runtime
  • I also skipped the PPA part cause mine was working fine without it
  • And instead of using TDSM (which is outdated, for Terraria 1.1) I used TShock (for Terraria 1.2)
  • I copied a pre-created Large World to my Pi via SSH, the world was about 50MB
  • I ran the server with screen and then "mono TerrariaServer.exe"

And I left it on for about longer than 12 hours (not really precise I know). I was the whole day gone, didn't SSH into it and nobody logged in on the server (I was just testing for crashes, nothing much).

So I came home and SSH'ed on my Pi. I could log in, and then the problems came. I couldn't execute any command not screen to reopen my session and couldn't even reboot or shutdown it without using the unclean way.

I got this when typing a command:

bash: fork: cannot allocate memory

How can I prevent this to happen? Or do anyone of you know solutions or alternatives?

3 Answers 3


You are going to have to restart your Raspberry Pi (probably by unplugging it, since you can't run the shutdown or reboot commands). You may have to reflash your SD card if this corrupts your image.

Some process is leaking memory, so other programs can't use it. To get an idea of what is causing this, run:

ps --sort -rss -eo rss,pid,command | head

You will probably see the Terraria server is the issue. You could contact the developers to let them know about it, and they might fix it in a future update.

Unfortunately, there is not much that you can do to prevent this, since it can only be solved by program developers properly allocating and freeing memory in the source code.

  • 1
    Thanks for your fast answer! I had to do what you said in the first paragraph, fortunately my SD survived :) I know a little bit of the linux terminal and things but I didn't know this! Thank you
    – Subject
    Oct 28, 2013 at 20:20
  • @ShivamRamkisoen Glad it worked out for you!
    – syb0rg
    Oct 29, 2013 at 3:14

Did you try using a SWAP-File?


The Tutorial is in German but the commands should be the same ;)

  • Sorry for the late response, I'll try it! It's christmasholiday right now over here so I have the time for it :)
    – Subject
    Dec 20, 2013 at 12:33

Since answers that link to other sites are discouraged, I am summarizing the procedure from the link @Senten provided. All credits to these instructions go to the author of the linked site, Jan Karres.

1) All commands should be issued as root:

sudo su

1.5) If you have previously uninstalled dphys-swapfile:

apt-get install dphys-swapfile

2) Set the swap file size to double the amount on RAM:

echo "CONF_SWAPSIZE=512" > /etc/dphys-swapfile
dphys-swapfile setup

If you have 512 MB RAM on the Pi then set swapsize to 1024.

3) Enable swap

dphys-swapfile swapon

4) Exit the root shell


And that's it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.