Swap space issue.

Hi,

I am not sure how many scripts / java processes running on my HP-UX server.

I need to calculate the total heap of these processes.

I then need to recommend increasing the swap memory to be increase and equal to total heap if that is the right concept.

Currently we are facing high swap memory usage and are unsure to what amount it needs to ne increased to.

Please help me with script or command to achieve the above.

You may use the top command in this case. Use top to get a snapshot of the processes along with the memory consumption.

top -f top.out -n 10000 -d 1

This redirects the output to top.out file with max. 10000 process listing (hopefully that's enough for you) and it does this for only one iteration.

Now you have to sort the result for RES and SIZE columns. SIZE gives you the total virtual memory consumed by a process in KB. RES gives is equivalent to the real memory consumption of a process in KB. So, if you deduct RES from SIZE for every process and then add them all, you should get closer to the least amount of swap memory needed for running the processes.

By the way, as you may be aware of, increasing the swap memory does not actually increase the performance for long. You may need to invest in more RAM.

If locally written applications are running the system out of swap space, they can change storage from malloc()/new (make space on the VW which is backed/rolled out on swap) to files attached with mmap() or the JAVA equivalent. The files in mmap are used as backing store, so all RAM is there to cache the access, but no swap is used. Reading and writing are just memory accesses. If an app crashes, the data from RAM pages will be written by VM, which can help debugging. This not only reduces swap space usage, it reduces swap traffic.