[CentOS] Swap memory: I can't reconcile this stuff.

Tue Jun 6 13:11:58 UTC 2006
Les Mikesell <lesmikesell at gmail.com>

On Tue, 2006-06-06 at 07:31, Kai Schaetzl wrote:
> Les Mikesell wrote on Mon, 05 Jun 2006 21:29:52 -0500:
> 
> > It's paged on demand.  Instead of thinking about memory being 
> > swapped out, think about it never being read from disk into 
> > memory until the memory that is supposed to hold it is accessed.
> 
> "never being read from disk" implies that there was something written to 
> the disk first. In that case the swap usage figure from top or free would 
> be wrong, wouldn't it?

The executable and it's libraries were written to disk a long
time ago.  When you start to execute it, the virtual memory
is allocated but the disk contents aren't loaded into memory
until there is an access to the virtual page.  In very old versions
of unix, executables were actually copied into swap but now
they just page in directly from their own disk file and never
need to be written back out.  From the virtual memory perspective
it is just a matter of which disk block needs to be loaded to
initialize the memory page if something ever accesses it.

-- 
  Les Mikesell
   lesmikesell at gmail.com