4

I am on a Linux machine and use openjdk7. After finding my code was executed twice as fast when using the -server option, i dove deeper into what was happening inside the VM and found that the Server VM inlines my code like crazy, while the Client VM does not inline at all.

Is this normal behavior?

kutschkem
  • 7,826
  • 3
  • 21
  • 56
  • 1
    The Server VM expects that the programs runs for a 'long' time therefore more complex optimization is done. Often it is useful to use the server VM but the inlining may lead to much more memory consumption. – MrSmith42 Jan 23 '13 at 13:05
  • If you're looking at changing the mode you JVM operates in you also need to make sure you are aware of the potential implications for visibility in a multi-threaded application as the switch can have unintended consequences due to the policy differences that allow reordering of operations between modes. – codeghost Jan 23 '13 at 13:09
  • To deeper understanding in differences you can look at http://stackoverflow.com/questions/198577/real-differences-between-java-server-and-java-client – Taky Jan 23 '13 at 13:14

1 Answers1

3

It is normal behaviour.

The server JVM optimises the code more heavily. This uses more CPU on startup and more memory when it is running.

The client VM is designed to quick start up e.g. applets. It is the default on Windows 32-bit JVMs only.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
  • 1
    so the client vm does not inline at all? And if -server is the default, why do i see the difference? (i did not specify that i wanted the client VM) – kutschkem Jan 23 '13 at 13:15
  • ok i figured it out, my java vm defaults to -client for some reason. – kutschkem Jan 23 '13 at 13:47