Query regarding swap memory

Hi,

Please help explain and answer the below:

  1. I need to predetermine how much swap will my JVM use if it is started with
-Xms 512M 

and

-Xmx 1024M

?

  1. Can a JVM process just use the Heap and not the Swap memory ?

  2. If the Total physical RAM on my server is 8 GB and current Heap utilisation is also 8GB(using the

vmstat

command), can I start a JVM process so that it just uses the swap memory ?

  1. what will happen if the swap memory is 100% full and and heap memory is 2 GB free. Will i be able to start a JVM process with 512M xms and xmx ?

Based on the nature of my questions if you have something related to this topic that can give me a better understanding on this topic Kindly share.

Your questions suggest a bit of confusion between memory and swap; I'll try to explain.

swap is used as a holding area for RAM. When memory gets low, RAM which hasn't been used recently gets copied into swap space then recycled, given to something else. When something tries to use memory which has been copied into swap, it's forced to wait for it to be read back out of storage.

You don't allocate memory versus swap -- it's the same thing as far as a userspace program's concerned. Traditionally, any memory is backed by its own area of swap anyway. It doesn't get used unless needed, but it's there. So you'd want to have at least as much swap as RAM, and potentially more.

This makes it possible to use more memory than you have RAM, by copying excess things into swap so it can make up the difference. This has a significant performance cost, because swap space on disk is much slower than RAM.

I would like to add one more question in this discussion.

Can anyone explain the use of

swap -s
swap -l

??

You should explain what your system is. Mine doesn't have that command at all.

vivex-goel-piet runs Solaris 9 (according to another post). All my links to the very old online manuals don't work any more since Oracle revamped the website. He could of course type "man swap" and post the bit of the manual he doesn't understand.

If the above were true, why does my swap memory increase in size which means something less used from the RAM was transfered to the swap memory even when the process I am starting is -xms=512M and -xmx=512M and the Total current free RAM is 4 GB.

It should ideally allocate 512M from the free 4GB of RAM rather than freeing up space on the RAM inorder to accomodate 512M process.

Can you please explain?

You cannot. It depends on all sorts of factors.

Yes. Whether it does or does not depends on all sorts of factors.

No.

Your questions indicate that you have little understanding of how virtual memory works on Unix/Linux or how memory management works in JVM. I recommend that you spend so time researching the subjects.