Understanding RAM vs swap usage?

Understanding RAM vs swap usage?

Post by Dean Neuman » Sat, 30 Jan 1999 04:00:00



Someone please help me figure this out...

"top" shows:
        Memory: 128M real, 63M free, 16M swap in use, 113M swap free

"swap -s" shows slightly different numbers than top:
        total: 36240k bytes allocated + 15080k reserved = 51320k used,
                177004k available

"swap -l" shows: (I'm aware these values are 512byte blocks)
        swapfile             dev  swaplo blocks   free
        /dev/dsk/c0t3d0s1   32,25      8 262952 230832

"df -k /tmp" shows:
        Filesystem  kbytes    used   avail capacity  Mounted on
        swap        175980    1052  174928     1%    /tmp

Although I know that Solaris caches disk data in RAM if possible, how is
it that I have 63MB of RAM available and yet have 16MB of swap in use
(according to 'top') only 1MB of which can be attributed to files in
/tmp?

My system, (2.6 on SS5) right after a reboot, with 1 user logged in
running a CDE session, shows 48M free and 0M swap in use.  The next
morning, it shows 63M free but 16M swap in use.

I suspect one of the nightly cron jobs must use all available RAM,
causing some other process to have it's data swapped to disk.
Apparently, since I now have 63M of RAM free, the hog process must have
exited or returned it's memory,
but the process whose data was swapped to disk remains with it's data on
disk.

Does this mean that "once on disk, always on disk"?  If this is a
persistent process, will it be slower than necessary forever because of
the hog process that for some small period of time used all available
RAM?

And how can I find out which process has this 16M of swapped data, and
which process used all the RAM?
I tried  "fuser /dev/dsk/c0t3d0s1"  but that doesn't show anything
useful.

Thanks gurus.

--
Dean Neumann
Neumann & Associates Information Systems Inc.
http://www.neumann-associates.com

 
 
 

Understanding RAM vs swap usage?

Post by Barry Margoli » Sat, 30 Jan 1999 04:00:00




Quote:>I suspect one of the nightly cron jobs must use all available RAM,
>causing some other process to have it's data swapped to disk.
>Apparently, since I now have 63M of RAM free, the hog process must have
>exited or returned it's memory,
>but the process whose data was swapped to disk remains with it's data on
>disk.

>Does this mean that "once on disk, always on disk"?  If this is a
>persistent process, will it be slower than necessary forever because of
>the hog process that for some small period of time used all available
>RAM?

Once it's on disk, there's no need to remove it from there.  Maybe if swap
space got completely full, the disk pages that are redundant might get
reused, but otherwise what's the point?

It shouldn't be slower forever.  When you reference that piece of memory,
it will get paged into RAM, and it will stay there as long as there's
memory available.  It will still be on disk as well, but it doesn't have to
be accessed there while there's also a copy in RAM.

--

GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Don't bother cc'ing followups to me.

 
 
 

Understanding RAM vs swap usage?

Post by Casper H.S. Dik - Network Security Engine » Sat, 30 Jan 1999 04:00:00


[[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]


>"top" shows:
>    Memory: 128M real, 63M free, 16M swap in use, 113M swap free

This swap is "actual swap on disk".

Quote:>"swap -s" shows slightly different numbers than top:
>    total: 36240k bytes allocated + 15080k reserved = 51320k used,
>            177004k available

This is "virtual swap" (physmem + disk swap)

Quote:>"swap -l" shows: (I'm aware these values are 512byte blocks)
>    swapfile             dev  swaplo blocks   free
>    /dev/dsk/c0t3d0s1   32,25      8 262952 230832

Yep, about 16M of stuff moved to disk.

Quote:>"df -k /tmp" shows:
>    Filesystem  kbytes    used   avail capacity  Mounted on
>    swap        175980    1052  174928     1%    /tmp
>Although I know that Solaris caches disk data in RAM if possible, how is
>it that I have 63MB of RAM available and yet have 16MB of swap in use
>(according to 'top') only 1MB of which can be attributed to files in
>/tmp?

Some stuff has been moved to disk because of earlier memory pressure or
because the page scanner felt those pages were really unused.

Quote:>I suspect one of the nightly cron jobs must use all available RAM,
>causing some other process to have it's data swapped to disk.
>Apparently, since I now have 63M of RAM free, the hog process must have
>exited or returned it's memory,
>but the process whose data was swapped to disk remains with it's data on
>disk.

Correct, why pull stuff from disk when you don't need it?

Quote:>Does this mean that "once on disk, always on disk"?  If this is a
>persistent process, will it be slower than necessary forever because of
>the hog process that for some small period of time used all available
>RAM?

No.  But don't forget that every process has a lot of data that is maybe
used once; once paged out, it's never needed again.

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.