LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-04-2008, 03:51 AM   #1
SBN
Member
 
Registered: Jul 2006
Distribution: UBUNTU, CentOS, FEDORA 8
Posts: 474

Rep: Reputation: 30
Swapping vs Paging vs Virtual Memory


Hey guys i have a hard time differentiating these 3 swapping, paging, virtual memory... im confused, im mixing them up.
 
Old 04-04-2008, 06:27 AM   #2
blacky_5251
Member
 
Registered: Oct 2004
Location: Adelaide Hills, South Australia
Distribution: RHEL 5&6 CentOS 5, 6 & 7
Posts: 573

Rep: Reputation: 61
Can't claim to be a kernel guru, but I always thought these were the same thing - just different names. All refer to data being moved from RAM to external (typically hard disk) until it is needed again.
 
Old 04-04-2008, 08:09 AM   #3
wilsonsamm
Member
 
Registered: Aug 2005
Location: Sheffield, UK
Distribution: Gentoo
Posts: 105

Rep: Reputation: 15
Yes but that's not always how it works: some 8 bit machines have ways of disconnecting (often 16K banks of) RAM and then reconnecting other banks to the then empty space in the adressing space . . . This is PAGING and is largely deprecated these days because we have fancy new computers with larger adressing spaces than 64K.

But SWAPPING means that you take data in the RAM and write it to disk (or mag tape or flash or whatever) thereby freeing that memory for later use.

This is at least how I understand it.
 
Old 04-04-2008, 09:51 AM   #4
ak_random
Member
 
Registered: Jun 2007
Location: Silicon Valley, CA
Distribution: Xubuntu
Posts: 83

Rep: Reputation: 15
Try here:
http://en.wikipedia.org/wiki/Swapping
http://en.wikipedia.org/wiki/Paging
http://en.wikipedia.org/wiki/Virtual_memory
 
Old 04-05-2008, 09:06 AM   #5
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Perhaps will the following explanation make these terms clearer (or add to the confusion ...)

Virtual Memory is where all Unix/Linux userland processes live. That means for example that the byte at address 0x00012345 isn't the same one for one process and any other one. A broken program cannot corrupt but its own memory thus processes are protected from the other ones.

This virtual memory is managed by a hardware component, the MMU, in charge of mapping physical memory (RAM) to virtual memory.When there is no room to store in RAM all of the processes used virtual memory, the OS has to do something to recover free RAM.

One old solution is to displace a process memory completely toward a dedicated part of the disk. This is called swapping (out) and the disk area is called the swap space. Swapping is not used that much by modern OSes for being inefficient in most cases (but not all). It is unimplemented with Linux but is available with most other Unix and Unix like OSes.

An alternative and common solution is to identify the less active parts of processes virtual memory and store them on that same disk area. This is called demand paging. The memory is stored in usually fixed size contiguous blocks called pages. Paging is often confused with swapping due to the storage area being called swap in both cases. As Linux doesn't support swapping anyway, the term is used interchangeably with paging in this context.

Depending on the OS used and its configuration, the situation where the swap area is also full may happen while memory reservation (malloc) was previously accepted anyway. In that case, the OS pick some process and just kill it. This is the controversial OOM Killer.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between resident memory,shared memory and virtual memory in system monitor mathimca05 Linux - Newbie 1 11-11-2007 04:05 AM
RH9, memory paging problems? Not physical NssOne Red Hat 3 04-23-2004 12:34 PM
virtual memory paging problem on install j_hart Linux - Software 0 10-13-2003 01:52 AM
Memory Allocation/Paging/Process Identification Kiada Linux - General 2 09-29-2003 03:57 PM
RH 7.3 not swapping memory...? severedhead Linux - Distributions 4 05-28-2002 05:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:11 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