January 21, 2021
Hot Topics:

Limiting JVM on VPS (Virtual Private Server)

  • By Serge Bornow
  • Send Email »
  • More Articles »

4. Another trick

alias java='java -Xms32m -Xmx128m'

On *Nix systems, this alias would work just fine.

Up to this point, you should be able to find a solution that would let you run JVM within your VPS Hosting account. Below you will find a crucial difference between two important options for a JVM. Remember that when JVM evaluates the system on which is resides and finds out that RAM exceeds 2 gigabytes, it assumes that your system is a server for its use and will assume the option -Server.

java -server versus java –client

Sun's document on Java Hot Spot states:

J2SE 5.0 provides two implementations of the HotSpot Java virtual machine (JVM):

  • The client VM is tuned for reducing startup time and memory footprint. Invoke it by using the -client JVM command-line option.
  • The server VM is designed for maximum program execution speed. Invoke it by using the -server JVM command-line option.

By default, the Application Server uses the JVM setting appropriate to the purpose:

  • Platform Edition, targeted at application developers, uses the -client JVM flag to optimize startup performance and conserve memory resources.
  • Enterprise Edition, targeted at production deployments, uses the default JVM startup mode. With J2SE 5.0, the HotSpot VM provides server-class machine detection, which will use the server VM if it detects "server-class" hardware (at least two CPUs and 2 Gb of physical memory).

This is quite important because VPS servers are usually fully loaded with at 8 Gb of RAM or more to cater to more users on a single machine; therefore, JVM is quite happy with those numbers.

Fortunately, there are many different virtualization applications on the market, both commercial and open source, and provide different ways to configure the limits for each account; therefore, the JVM would not be able to detect such limits and assume default values.

Limiting Ant's Use of RAM

ANT is a neat and most popular build tool and is commonly used. Glassfish utilizes ANT as a way to install itself. You will be pleased to hear that you can limit its use of memory by using this variable:



VPS hosting is the optimal and most affordable way to host your J2EE application, yet it isn't very easy to initially set up JVM to work as you wanted. The final result will be worth the effort.

Helpful Links

About the Author

Serge's picture

Serge Bornow works as a freelance consultant in J2EE and .NET.

His main interests are most current open source projects in J2EE, Ajax, and web development. He also plays tennis and enjoys traveling around the world.

Page 2 of 2

This article was originally published on August 31, 2007

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date