-Xmx -Xms and paging
I have a 64 bit windows box with 2gigs.
The operating system takes 600 mgs.
If I do this:
-Xmx2000m -Xms512m
will it page (ie use virtual memory) only when it needs to and then stop using virtual memory when memory consumption goes back down?
In other words I have an algo that can spike in terms of memory, but I would like to know if after one of these spikes it can ever stop paging, or will the vm get in this case its 2gig of memory and the os will presume that it has to page?
thanks.
[536 byte] By [
kentkenta] at [2007-11-27 4:30:38]

You should always make the heap size less than the amount of memory you have on your machine. Just how much less depends on what else you have running. The java garbage collectors are not written to handle heaps that get swapped out to disk. If you only have 2 gig of physical memory, and you are running with a 2 gig heap, you will be paging like anything if you even start approaching that 2 gig limit and the performance will be terrible.
If you really have no option then google for MaxHeapFreeRatio.
> will it page (ie use virtual memory) only when it
> needs to and then stop using virtual memory when
> memory consumption goes back down?
>
Depends on the JVM implementation.
Some will release memory no longer needed after garbage collection, some will not, some may be smart enough to keep track of memory requirements over time and try to predict if that memory will be needed again soonish and keep it if so.
Whether it will page or not depends on your operating system and available hardware, not the JVM.