-Xms Question for long (French) week end


Hi all,

Before leaving in a 4 days week end (July 14th is Bastille Day ;o)) I would like to like to get your inputs regarding -Xms Sun JVM’s option.

This week I tried to find the best way to manage memory usage of our Eclipse’s based product. This work led me to ask my self How should I manage OutOfMemoryErrors and also bring me to -Xmx and to the mysterious (to my blinded eyes) -Xms option.

In our product we are setting -Xmx to 512m. All is clear and works perfectly with this option.

Regarding -Xms things are more complicate (once again, to my blinded eyes).

Sun “Tuning Garbage Collection” document says: “If the value of -Xms is smaller than the value of the -Xmx parameter, not all of the space that is reserved is immediately committed to the virtual machine”

I am wondering :

  • What “is immediately committed” exactly means ? Does it concern other running applications to the system ?
  • What’s the best value for -Xms is order to increase product performances and in order to not decrease other system applications performances ?
  • Is there any drawback to set this -Xms option to the same value than -Xmx ?? I am not a system expert at all, but it seems that setting this -Xms option to an high value doesn’t affect other running applications …
  • Is there any Virtual memory management relationship there ?

I would appreciate any Java expert comment on that topic in order to have a clear view of what this -Xms option really do and to use it.

Thanks in advance and have a nice week end.

Manu

Advertisements

3 thoughts on “-Xms Question for long (French) week end

  1. -Xms sets the heap allocated on VM start. Increasing it to the amount of memory your product typically needs will save you a few garbage collections and extra memory allocations during startup.

  2. From the java command manual it’s clear what those commands are used for.

    -Xms is the initial (read the minimum if you want) heap size.
    -Xmx is the maximum heap size.

    From my experience, what is said in the doc to be the initial size is in fact like a threshold before the garbage collector starts running.

    From the start of your JVM, a small amount of memory is allocated, and this one grows each time you need more memory. When -Xms value is reached, instead of directly allocating memory, the JVM tries to get back some by running the GC. At that time, if no memory is freed by the Gc, new memory is allocated, up to the -Xmx value.

    So, it depends on the kind of application you work on, if it’s a desktop one, you will try to let some memory for other applications.

    If it’s a server one, it’s probably ok to reserve the memory dedicated to your application.

    From a performance point of view, this involves running the GC or not before allocating memory, it’s in fact the time your are ready to spend running GC.

    Hope this help… and it does not contain too many errors ;-)

  3. Setting -Xms tells Java how much memory the application gets right when starting up, regardless of whether it needs it or not.

    It concerns other apps as any other memory that is in use: you don’t have it available for other apps. Depending on your resources this can mean swapping memory to HDD.

    Another drawback (except of not having that memory available for other apps of course) of giving Java too much memory to handle is, that although a full garbage collection does not happen that often, it might take slightly longer, as there is more memory to handle.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s