Operating System - HP-UX
1834494 Members
3008 Online
110067 Solutions
New Discussion

shared memory and swapinfo output

 
SOLVED
Go to solution
Jdamian
Respected Contributor

shared memory and swapinfo output

Hi guys.

My box holds two Oracle databases whose SGAs occupy 2 GB aprox.

ipcs -ma | grep oracle
m 840707 0x7d4ba85c --rw-r----- oracle dba oracle dba 9 1061339136 27372 1620 12:52:40 13:16:25 13:23:32
m 12292 0xb87b04f4 --rw-r----- oracle dba oracle dba 49 1094467584 22456 2880 17:32:46 17:32:47 16:40:11

The problem is output of 'swapinfo -tam' doesn't show 2 GB are in use:

# swapinfo -tam
Mb Mb Mb PCT START/ Mb
TYPE AVAIL USED FREE USED LIMIT RESERVE PRI NAME
dev 1024 0 1024 0% 0 - 1 /dev/vg00/lvol2
dev 1024 0 1024 0% 0 - 1 /dev/vg00/lvol13
dev 1024 0 1024 0% 0 - 1 /dev/vg00/lvol10
reserve - 2318 -2318
memory 3091 668 2423 22%
total 6163 2986 3177 48% - 0 -

As shared memory is locked memory (as found in white paper "HP-UX Memory Management" available in your box at /usr/share/doc/mem_mgt.txt) it will never be swapped out and it reduces the amount of physical memory available for other processes... Therefore, the line "memory" should print less free memory -- At least, the "MB Used" should be greater than 2GB.

Any idea ?
6 REPLIES 6
Cesare Salvioni
Trusted Contributor

Re: shared memory and swapinfo output

The memory line is NOT the available memory for processes, but the PSEUDO SWAP enabled by system, that is to say the amount of swap that the system pretend th have reserved but do not really reserve on swap devices.

from this command u get only info about swapping, not about memory usage, u should use top or vmstat to see the amount memory pages used
Kent Ostby
Honored Contributor

Re: shared memory and swapinfo output

vmstat will list free pages. You need to multiple that by 4096 to get amount of free mem.

The "avm" should show you your average amount of memory that has been used over the last 5 minutes.

"Well, actually, she is a rocket scientist" -- Steve Martin in "Roxanne"
Jdamian
Respected Contributor

Re: shared memory and swapinfo output

Sorry Cesare, but I don't think so.

When system uses pseudo-swap is because all space in dev and fs swap is reserved. When system uses memory pages as pseudo-swap, those pages are LOCKED in memory (LOCKED means they won't be swapped out because ... there is no space in disk reserved for this pages). Then the percentage of memory free in this "memory" line is decreased. The problem is that others than swapper can LOCK memory pages and causes to decrease the free memory percentage -- some processes may call plock(), mlock() or shmctl() or other system calls to lock memory.

In my case, swapinfo tells there are 2423 MB free from a pool of 3GB, but how is it possible if 1 GB is already locked as shared memory ?
Borislav Perkov
Respected Contributor

Re: shared memory and swapinfo output

Hi,
Cesare is wright, the system pretent that it has reserved swap memory, so called pseudo swap, that is because of application need of virtual memory.
Example: if there is 5 applications and they need 20 MB of additional memory each to start working (but they will not use it completely), in case you have only 70 MB virtual memory all 5 applications can't work at once because they "need" 100MB. Those 30 MB extra will be "reserved" from nonexist pseudo swap.
Regards,
Boris
Steve Lewis
Honored Contributor
Solution

Re: shared memory and swapinfo output

Shared memory segments are only locked in memory if the creating process calls shmctl() with the SHM_LOCK flag. I don't know if Oracle does this or not.

If you compile and run the attached C program, your memory usage will become a lot more clear. Any user can run it.

compile with cc -o meminfo meminfo.c

It may help us if you post the results.

Jdamian
Respected Contributor

Re: shared memory and swapinfo output

Thanx Steve.

Today I've learned that not all shared memory is locked.

I've written this little C program:

#include
#include

int main()
{
int myshmid;

myshmid = shmget (IPC_PRIVATE, 512*1024*1024, 0600);
shmctl(myshmid, SHM_LOCK, 0);

printf("sh id: %d\n",myshmid);
}

This program creates a shared memory segment whose size is 512 MB.

If shmctl() is present, swapinfo reports increments of percentage in pseudo-swap memory.
If shmctl() is removed from program, pseudo-swap memory is not changed, but reserved swap is increased in 512 MB.