LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Applications in Swap (https://www.linuxquestions.org/questions/linux-newbie-8/applications-in-swap-379713/)

droz578 11-03-2005 04:41 PM

Applications in Swap
 
I'm currently trying to locate which processes are in the swap space and how much memory that processes is using. Could someone help me tell the correct program to locate this...

foo_bar_foo 11-03-2005 10:29 PM

applications per say aren't in or out of swap space the way it might be in some very old legacy operating systems. swap is used only to store non media backed anonymouse data and the data that is swapped out is in relation to it not being accessed in a while. virtual page mapping as far as i know is non contiguous but you might be able to figure out what is in swap by looking in the /proc filesystem
if you understand memory addresses ? I know i can't figure it out.

btmiller 11-03-2005 11:07 PM

You won't be able to tell from the memory address. When a page is swapped out all the will happen is that that page will be marked as invalid in the process' page table (and there's some other accounting records to show how to find it in swap). One thing to do is run top, and then press the "f" key to choose what fields are shown. Modern versions of top will have the ability to display the amount of the process that's currently swapped (pressing P in the field selection in my version of top).

droz578 11-04-2005 07:42 AM

Thanks for the information

foo_bar_foo 11-04-2005 10:29 PM

Quote:

Originally posted by btmiller
. One thing to do is run top, and then press the "f" key to choose what fields are shown. Modern versions of top will have the ability to display the amount of the process that's currently swapped (pressing P in the field selection in my version of top).
fascinating
i think this means it is actually spelled out in /proc somewhere -- all top does is parse /proc
possibly /proc/<PID>/statm or something
would have to make machine use swap to check it out -- a task for another day

foo_bar_foo 11-04-2005 10:58 PM

OK i tried this and the SWAP output from top is crap
it's just SWAP = VIRT - RES

that tells us exactly nothing
back to squARE 1


if we can identify dirty anonymous pages
and determine if they have ever been ejected
then there we have swap yes


syg00 11-05-2005 12:22 AM

Quote:

Originally posted by foo_bar_foo
OK i tried this and the SWAP output from top is crap
it's just SWAP = VIRT - RES

that tells us exactly nothing
Huh ????
That would be precisely my definition. Could probably be (more logically) expressed as "VIRT = RES + SWAP".
What have dirty pages got to do with the swap discussion - if they are dirty they are "pinned" in physical memory, and so are included in the resident count.
If they are anonymous, and have been swapped out, they are in the SWAP count - and increase the VIRT size accordingly.

I haven't looked specifically at the code for this, but seems logical to me.

foo_bar_foo 11-05-2005 11:45 AM

Quote:

Originally posted by syg00
Huh ????
That would be precisely my definition. Could probably be (more logically) expressed as "VIRT = RES + SWAP".
What have dirty pages got to do with the swap discussion - if they are dirty they are "pinned" in physical memory, and so are included in the resident count.
If they are anonymous, and have been swapped out, they are in the SWAP count - and increase the VIRT size accordingly.

I haven't looked specifically at the code for this, but seems logical to me.

well lets see,
Code:

(12:31pm:11/05/05)
(gary) ~  $ free
            total      used      free    shared    buffers    cached
Mem:      1033040    253984    779056          0      15224    131248
-/+ buffers/cache:    107512    925528
Swap:      2096472          0    2096472

so 0 swap used and still 2/3 of my physical RAM unused
so lets look at what you said for startx
Code:


  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  SWAP COMMAND                                   
 1006 gary      17  0  4684 1320 4224 S  0.0  0.1  0:00.00 3364 startx

3364 SWAP used by startx
with 0 swap actually used and lots of physical RAM free

it seems rather obvious that all the virtual memory is not in either swap or resident
but is "virtual" duhhhh.

and clean anonymous pages under memory pressure just get ejected not written to swap because they contain nothing at all so dirty has something to do with it.

syg00 11-05-2005 09:32 PM

O.K. I'll shut up and go back and hide under my rock ...

I've always been happy to accept VIRT = RSS + SWAP.
Maybe that's just a convenient shorthand for "VIRT = RSS + all the other bits" ... :p
Those numbers do need some explaining that is beyond me. May just be an issue with the way "top" calculates and/or presents the numbers, although meandering through /proc/<pid>/status also shows some (lesser) annomalies.

Dunno ...


All times are GMT -5. The time now is 09:34 PM.