Operating System - HP-UX
1837230 Members
2161 Online
110115 Solutions
New Discussion

To determine the right value to increase swap space

 
SOLVED
Go to solution
Ahmad Munawwar
Frequent Advisor

To determine the right value to increase swap space

 
15 REPLIES 15
Stefan Farrelly
Honored Contributor

Re: To determine the right value to increase swap space


Youve got 256MB of RAM and your USED device line from swapinfo is 364MB !! This means youre using 256+364 = 620MB of RAM and you only have 256. Your server must be performing like a snail. Increasing swap will not help - you simply have to either add more physical RAM or reduce the amount of processes running on your server!

You will find to maintain good performance most admins will keep some free RAM - ie. no swapping (Device line from swapifo always shows USED = 0). We do or else performance is terrible.
Im from Palmerston North, New Zealand, but somehow ended up in London...
Michael Tully
Honored Contributor

Re: To determine the right value to increase swap space

Seems that you really don't have a lot of RAM, you should invest in some more. 256Mb is extremely small these days, and purchasing more is not that expensive. Increasing your swap space past 2x in my opinion is not really the answer. Has this grown over time (memory usage/swap usage) or just happened?
Anyone for a Mutiny ?
Pete Randall
Outstanding Contributor

Re: To determine the right value to increase swap space

Double (at least) your physical RAM. You will then need to adjust your swap space to match your RAM (double is probably good with such a small amount of RAM).


Pete

Pete
V. V. Ravi Kumar_1
Respected Contributor

Re: To determine the right value to increase swap space

hi,

swap space setting is correct on ur system. instead u should increase the RAM on ur machine at least to 1GB with 2GB swap space.

Regards
Never Say No
Khalid A. Al-Tayaran
Valued Contributor

Re: To determine the right value to increase swap space


Hi,

Add RAM to your system and set 2 * RAM as swap. (Also depends on the application you're using actually)
Michael Steele_2
Honored Contributor

Re: To determine the right value to increase swap space

I would add some swap because it will probably help your case.

Physical memory is finite space that uses swap as a temporary work area when filled. In your case you've not only hit the ceiling of physical memory but you've also hit the ceiling of your temporary work space. (* You got to be able to flex out somewhere *)

85% total used swap is the test for adding swap. If you have the disk space then add 256 mb:

lvcreate -L 256 -n swap -C y -r n /dev/vg##

swapon -f -p 1 /dev/vg##/swap

/etc/fstab
/dev/vg##/swap ... swap pri=1 0 1

In short, your system is probably slow and adding more swap isn't going to make it any worse, so go ahead and try.
Support Fatherhood - Stop Family Law
Ahmad Munawwar
Frequent Advisor

Re: To determine the right value to increase swap space

Hi,

Thank for your input, I thought of rebooting the machine before proceed with adding swap space and physical memory and suprise after rebooting the machine the memory usage has tremendous improvement as you can see below (compare to above result):

sdp_ws1:root> swapinfo
Kb Kb Kb PCT START/ Kb
TYPE AVAIL USED FREE USED LIMIT RESERVE PRI NAME
dev 524288 0 524288 0% 0 - 1 /dev/vg00/lvol2
reserve - 99852 -99852
memory 178016 37644 140372 21%
sdp_ws1:root> swapinfo -ta
Kb Kb Kb PCT START/ Kb
TYPE AVAIL USED FREE USED LIMIT RESERVE PRI NAME
dev 524288 0 524288 0% 0 - 1 /dev/vg00/lvol2
reserve - 99852 -99852
memory 178016 37644 140372 21%
total 702304 137496 564808 20% - 0 -
sdp_ws1:root> sam
sdp_ws1:root> vgdisplay /dev/vg00
--- Volume groups ---
VG Name /dev/vg00
VG Write Access read/write
VG Status available
Max LV 255
Cur LV 8
Open LV 8
Max PV 16
Cur PV 1
Act PV 1
Max PE per PV 2500
VGDA 2
PE Size (Mbytes) 4
Total PE 2168
Alloc PE 1191
Free PE 977
Total PVG 0
Total Spare PVs 0
Total Spare PVs in use 0

I aslo compared the result of the "UNIX95= ps -e -o vsz=Kbytes -o ruser -o pid|sort -nrk1" b4 & after the machine reboot:

b4 reboot:
131 processes running and total memory usage is 250MB

After reboot:
85 processes running and total memory usage is 47MB

Do you have any idea about this and does this processes will again start to eat the memory.

Regards,
Munawwar







Michael Tully
Honored Contributor

Re: To determine the right value to increase swap space

Hi Munawwar,

It seems you could have an application that has some sort of memory leak. The only way to eleviate this is to reboot your server. This will also release additional memory that these processes would be using.
In answer to your question about whether the processes will again start to use memory, I suspect so. The only way to tell for sure would be continuous monitoring of your system. If it keeps up, the only suggestion is to either get the application fixed that causes the problem, or by regular reboots.

Regards
Michael
Anyone for a Mutiny ?
Ahmad Munawwar
Frequent Advisor

Re: To determine the right value to increase swap space

Hi all,

Thanks for the guideline. I just wonder how should i maintain the processes for example in my case, the system had about 131 processes b4 reboot and 81 processes after reboot. there were about ~50 processes that actually running unnecesarily in the system and occupied lot of memory. without reboot how to determine & kill the process? is it safe to do that?

Regards,
Munawwar
malay boy
Trusted Contributor

Re: To determine the right value to increase swap space

For me I won't simply killed a process if I not sure what it's doing.Killing the process might cause application or O/S problem.

regards
mB
There are three person in my team-Me ,myself and I.
Michael Tully
Honored Contributor
Solution

Re: To determine the right value to increase swap space

What I would suggest is to take a snapshot every hour and keep this output. You could then compare from hour to hour what processes are actually running and how much they are in fact using.

Have a look in the 'scripts' posting, as there are a couple there that you could use. look for 'memory'

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x026250011d20d6118ff40090279cd0f9,00.html
Anyone for a Mutiny ?
Jack Werner
Frequent Advisor

Re: To determine the right value to increase swap space

Munawwar,

If your OS has "glance" then you can determine which running processes are using how much CPU% and which processes are hogging memory.

CIAO
i'm retired
Ahmad Munawwar
Frequent Advisor

Re: To determine the right value to increase swap space

My application could not start due to a large number of sleeping programs (processes ever started but never terminated). The kernel at its convinience will swap out or paged processes that are not using any CPU capacity. Rebooting the server will obviously clean out all the sleeping processes with that freeing the paging space on the swap dev. The following explain the concept of swap space:


*****************************************************************************************************

Swap space is an area on the disk that temporarily holds a process memory image. When physical memory demand is sufficiently low, process memory images are brought back into physical memory from the swap area on disk. Having sufficient swap space enables the system to keep some physical memory free at all times.



This type of memory management is often referred to as virtual memory and allows the total number of processes to exceed physical memory. Virtual memory enables the execution of a process within physical memory only as needed.

******************************************************************************************************

In my scenario, ones the system is in need for memory or when running processes are 'not in use for some time' then they will be stored in the swap area where they are in 'sleeping' state. This 'sleeping state' was called swapped or paged to swap area. That is why when I try to start the application that required more memory, the physical memory cannot handled because it cannot stored the sleeping processes to swap area because the swap area has already 70%.

Now, why the swap area went up to 70%. It is because as I explained in above, that the applications have been sleeping in the memory and never terminated which after sometime (x time at y load) the kernel decides to park the process in the device-paged area.

Thanks a lot for your invaluable info and support

John Meissner
Esteemed Contributor

Re: To determine the right value to increase swap space

I'd start by getting about a gig of physical RAM in your case... more if you can afford it. Then the swap size is normally 1:1 of the physical RAM... i.e. if you have 1 Gb of RAM you would normally have 1Gb of swap.

256 MB... ouch... yeah... it'd start there
All paths lead to destiny
Bill Hassell
Honored Contributor

Re: To determine the right value to increase swap space

Swap space is part of the virtual memory that HP-UX treats as memory. The good news is that you can run thousands of megs of processes in only 256 megs. The bad news is that performance may be extremely poor. As mentioned, 256 megs is terribly small, especially if you are running some commercial database program like Oracle or Sybase. You need several gigabytes of RAM.

Now it is certainly possible to start thousands of programs (like shells) which are interactive and most of the time are sleeping. HP-UX will page these idle proceses out to the swap area to make room for active processes. Buit once a number of processes start running at the same time, the page-out rate may jump to hundreds which will cause serious performance problems.

Note that idle processes will not cause memory problems until you run out of swap space. Since you are pushing the high end of swap space, I would add (at least temporarily) another couple of gigabytes of swap space. It's important to note that there are two types of memory used by programs: data and shared. The data area is part of the program and other than issue about needing more than 900 megs in a program or exceeding the maxdsiz parameter in the kernel, these programs will run OK (won't get 'out of memory' errors) as long as there is enough swap space. But shared memory is much more complicated as it is shared by several processes and for 32bit programs, comes from a multi-use area which can become fragmented.

So there are several issues going on here: swap space, small RAM, maxdsiz, 32bit programs, shared memory, and the answer will require detailed investigation to resolve (but be prepared to buy more RAM...you are strangling the computer with such a small amount of memory).


Bill Hassell, sysadmin