Ommadawn
Ommadawn

Reputation: 2730

Tomcat max RAM in a VPS

I'm going to upload my local Tomcat WebApp to a VPS. I have selected a 2GB RAM VPS, so... how could I know how many GB of RAM should I set in Tomcat for using? I mean, the server has 2GB, but I don't know if it's safe to set 2GB for tomcat or not.

Could anyone give me an advise?

Upvotes: 0

Views: 95

Answers (1)

Svetlin Zarev
Svetlin Zarev

Reputation: 15673

Setting -Xmx2g is a bad idea. You have to take several memory regions into account when deciding on memory settings:

  • How much RAM is used by the OS ?
  • Metaspace
  • Java Heap
  • Native memory (used by the thread stacks)

So your -Xmx should be a bit less than:

Java Heap = ALL_RAM - UsedByOS - MetaSpace - ExpectedNumberOfThreads * StackSize - other ram used by the jvm

Upvotes: 1

Related Questions