LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-03-2005, 04:41 PM   #1
droz578
LQ Newbie
 
Registered: Jan 2004
Posts: 6

Rep: Reputation: 0
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...
 
Old 11-03-2005, 10:29 PM   #2
foo_bar_foo
Senior Member
 
Registered: Jun 2004
Posts: 2,553

Rep: Reputation: 53
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.
 
Old 11-03-2005, 11:07 PM   #3
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
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).
 
Old 11-04-2005, 07:42 AM   #4
droz578
LQ Newbie
 
Registered: Jan 2004
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks for the information
 
Old 11-04-2005, 10:29 PM   #5
foo_bar_foo
Senior Member
 
Registered: Jun 2004
Posts: 2,553

Rep: Reputation: 53
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
 
Old 11-04-2005, 10:58 PM   #6
foo_bar_foo
Senior Member
 
Registered: Jun 2004
Posts: 2,553

Rep: Reputation: 53
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


Last edited by foo_bar_foo; 11-04-2005 at 11:05 PM.
 
Old 11-05-2005, 12:22 AM   #7
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,120

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
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.
 
Old 11-05-2005, 11:45 AM   #8
foo_bar_foo
Senior Member
 
Registered: Jun 2004
Posts: 2,553

Rep: Reputation: 53
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.

Last edited by foo_bar_foo; 11-05-2005 at 09:04 PM.
 
Old 11-05-2005, 09:32 PM   #9
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,120

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
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" ...
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 ...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux swap / solaris not appearing as swap in Ubuntu? Erik_the_Red Linux - Newbie 1 07-30-2005 12:57 PM
Adding new applications to "Applications" menu scng Fedora 1 07-03-2005 12:02 AM
How to unmount actual swap and mount a new(bigger) swap space? isaac Linux - Newbie 1 06-06-2004 01:23 AM
Who is Knowing about daemon applications and how to develop these applications? ms_890 Linux - Software 0 04-14-2004 02:04 AM
Difference between Swap Virtrual memory and Swap Parition Nappa Slackware 4 11-27-2003 07:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration