Jump to content
  • 0

Java OutOfMemoryError on multiplayer hosting


Friendlybandit

Question

Hello guys!

 

First, i'm not good at english, Because i'm korean sorry

 

Anyway i'm hosting my Project Zomboid public server But when many people come in my server The server Suddenly stops! And when i see my server CMD, Displays this error message

 

Java.OutOfMemoryError!

 

But my computer uses 8GM Ram and Windows 7 64bit

 

Please Help me!

 

 

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

Little copy-paste from StackOverflow:

Quote

The flag Xmx specifies the maximum memory allocation pool for a Java Virtual Machine (JVM), while Xms specifies the initial memory allocation pool.

This means that your JVM will be started with Xms amount of memory and will be able to use a maximum of Xmx amount of memory. For example, starting a JVM like below will start it with 256MB of memory, and will allow the process to use up to 2048MB of memory:


java -Xms256m -Xmx2048m

The memory flag can also be specified in multiple sizes, such as kilobytes, megabytes, and so on.


-Xmx1024k
-Xmx512m
-Xmx8g

The Xms flag has no default value, and Xmx typically has a default value of 256MB. A common use for these flags is when you encounter a java.lang.OutOfMemoryError.

When using these settings, keep in mind that these settings are for the JVM's heap, and that the JVM can/will use more memory than just the size allocated to the heap. From Oracle's Documentation:

Note that the JVM uses more memory than just the heap. For example Java methods, thread stacks and native handles are allocated in memory separate from the heap, as well as JVM internal data structures.

 

Link to comment
Share on other sites

Two possibilities come to mind: either you are using 32 bit java (and thus largely limited to 4 GB) or you've got a command line switch that you can use to increase the memory that you aren't using. The ProjectZomboidServer.bat looks like the following below:

 

@setlocal enableextensions
@cd /d "%~dp0"
SET _JAVA_OPTIONS=
".\jre64\bin\java.exe" -Xms2048m -Xmx2048m -Djava.library.path=./ -cp jinput.jar;lwjgl.jar;lwjgl_util.jar;sqlite-jdbc-3.8.10.1.jar;trove-3.0.3.jar;uncommons-maths-1.2.3.jar;./ zombie.network.GameServer
PAUSE

 

Now, the 'switch' I'm talking about is -Xmx2048m this is the effective maximum amount of memory allotted to java, the 'switch' before that is the minimum. Now, I'm assuming you are running this on your personal machine, and with windows 7 64 bit (generic) you are not going to be able to use all 8 GB of your ram.  What I'd suggest is starting out with -Xmx5120m which leaves you a cushion for running a few lower intensity apps. That leaves you with around 2.8 GB to use for the OS, and any extra applications you do run while the server is up. If you notice different issues with your OS you may need to lower the amount of ram I'd start by moving down to -Xmx4500m. Finally, you may have to adjust the maximum amount of players you can have on at a time. Being a public server I can see the desire to let as many get on as they want, but you'll find greater stability for your players if you set a limit that works for your machine. (No one likes crashes after all, developers, admins, and players alike.) Feel free to ask if you don't understand something specific; this information might help others in the future.

Link to comment
Share on other sites

I know I'm being maybe too cautious here, but maybe you could post whole OutOfMemory exception or a log (console.txt)?

Bottom line: Heap OOM is different from xGen and other OOMs, so you may need to perform different steps to get rid of them.

Log file (console.txt) is always a plus for developers when talking Java issues (it has Java version and architecture too).

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...