Skip to content

more info about finding out swap space used by the oracle instance – for the new oracle dba

a new oracle dba can find in this article information on how to find out the swap space occupied by the oracle instance and how to understand the info returned by the swap command.






swap -l shows physical swap space on disk/file(s) in 512-byte blocks.
swap -s shows swapfs space, which includes swap disk(s)/file(s),
but also includes free memory. When the system needs to allocate
anonymous space (heap, stack, shared memory, /tmp files),
it first allocates from memory. When memory gets low,
then the system typically starts paging to the swap device(s)/file(s).

The “available” value in swap -s is saying how much
reservable space is available. This includes free memory
and swap space on disk/file.

If this is still not clear, I have a simple program that demonstrates
the reservation system. Let me know and I’ll post it.


Here is the program:

char a[100*1024*1024]; / 100 MB of bss/heap /


If you want to try this, you’ll need a compiler.
gcc or sun studio work fine.

Here is before and after swap:

# swap -l
swapfile dev swaplo blocks free
/dev/dsk/c0d0s1 102,1 8 1052344 679000
# swap -s
total: 509920k bytes allocated 62748k reserved = 572668k used, 293036k available
# ./a.out & <– here is the 100MB program
# swap -l
swapfile dev swaplo blocks free
/dev/dsk/c0d0s1 102,1 8 1052344 679024
# swap -s
total: 509976k bytes allocated
165176k reserved = 675152k used, 190540k available

The reserved space went up by 100MB, the available space went
down by 100MB. The space on disk hasn’t really changed.
Now, if the program accesses the 100MB array,
space that was in the reserved field moves to the allocated
field. Used and Available don’t change. The
space on the swap device won’t change unless the system
starts getting low on memory and starts paging.

To see this, change the program as follows:

char a[100*1024*1024];

int i;

for (i = 0; i < 100*1024*1024; i+=4096) { / this works for 4k/8k pagesize /
a[i] = ‘x’;
if ((i % (1024*1024)) == 0)
sleep(5); /
pause every 1MB for 5 seconds /


Now, start up a simple script that runs swap -l and swap -s in
5 second intervals:

while true
swap -l
swap -s
sleep 5

In another window, run the second version of the program.

What you should see is the reserved space going the
the allocated column, roughly 1MB every 5 seconds.
If your machine starts running low on memory,
pages may be swapped out and the space
on the swap device will decrease. Note that the pages
being sent out may have nothing to do with this program.
The OS simply picks pages that have not been recently
referenced. The pages are not brought back into memory
until they are needed. So, even after you kill the program,
pages (of other programs) may be on swap even
though you have plenty of memory.

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Post a Comment

You must be logged in to post a comment.