Everytime someone runs out of memory in java, the people advise to set -Xmx and -Xms to an amount of memory. I know how this work, but the people allways say to use the same amount in Xmx and Xms like -Xmx256 -Xms256. Why setting the two paraemters the same ammount is better? Whats the disadvantage of doing something like this -Xms128 -Xmx256?
if you set an initial heap size lower than it max capacity, at some time jvm will need to do some memory reallocation, and that is time and cpu consuming. i think that's the reason why it's recommended to set both to the same value.
We had an application designed to run in 1.5Gb memory and we didn't notice any problem in allocating more memory. I don't doubt you, but do you have any more information?
We had to end up setting min and max memory to the same upper limit since we were using Toplinks WeakCacheHardIdentityMap, and this caching strategy would empty the cache before allocating memory, and would never get to the max size otherwise.
For a lot of applications, I think it's fine to use a smaller value for -Xms than for -Xmx. That allows the Java application to start off relatively small, but to grow if necessary.
However, there are some situations where this is not true. Here's two: -
If your Java application uses lots of Soft/WeakReference caches, then Java will flush these caches, before it increases the heap size. Therefore, with a small initial heap size, you may not get as much benefit from such caches as you would with a bigger initial heap size.
If other applications are negotiating for the memory available on the machine, then setting a small initial heap size may allow the other applications to get hold of all the available memory, so that Java cannot increase its heap when it wants to do so. We have this problem with our particular application, so we do set -Xms and -Xmx to the same value.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.