• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

large difference between -Xms and -Xmx values in jvm

 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Folks,

Could somebody please tell me the reason why it's not a good idea to have a much larger -Xmx value than an -Xms? The settings on my prod JRun4 box are set at -Xmx 256m and -Xms32m. I've read in places that these 2 values should be equal to each other.

- M.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
-Xmx is the maximum Java heap size, and -Xms is the initial Java heap size. If they're different, then the JVM process size starts small, and grows as needed. If they're the same, then the JVM starts out using as much memory as it will ever use.

It's useful to make them different if you want to be conservative about requesting memory from the OS. It's useful to make them the same if your process will run for only a short time, but will be performance-critical during that time. I don't think it's possible to make a single, general statement about one arrangement being better than the other.
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think that there are sometimes good reasons to have widely-different values for -Xmx and -Xms, and sometimes good reasons to use the same value for both.

Widely-different values would be a good idea if you have a program that might need a small or a large amount of memory, depending on information only available at run-time (e.g. user input). If you were to use the same value for both -Xmx and -Xms in this situation, then you would have to make it a very large value and that would waste the resources of the computer for runs when the requirement was actually small.

On the other hand, using the same value for both can boost overall performance, as no time is lost resizing the heap, or thrashing the GC, trying to work within a small heap. Another time when it is useful (one I have experience of) is when there is another application that grabs a large proportion of available memory. The Java application needs to claim enough memory straight away, otherwise this other application will claim it, and prevent the Java application from getting more later.
reply
    Bookmark Topic Watch Topic
  • New Topic