Re: VM system - memory seems to be running out, when it's not

From: Darren Dunham (ddunham_at_redwood.taos.com)
Date: 12/16/04


Date: Thu, 16 Dec 2004 19:12:52 GMT

Bernd Haug <bhau-news@efkon.com> wrote:
> In article <DQiwd.34717$zx1.8362@newssvr13.news.prodigy.com>, Darren Dunham wrote:
>> Correct as far as it goes, but very few things "reserve" memory on
>> Solaris (Oracle being one of the more popular that does). Instead, most
>> memory is "allocated", which comes from RAM preferentially, not disk.

> Yes, but if you fork, as I understand it, memory pages in RAM only get
> copied on write?

Correct. No extra RAM allocation would occur until the pages are used.

> But, since the process has gotten memory from the system, it can expect
> that memory to stay allocated, no?

The initial pages remain allocated and the extra space required by the
new process is reserved.

> Isn't that amount immediately reserved in swap so that the memory needs
> can be satisfied (if only in swap)

Yes.

>> You can see the current breakdown of your system with 'swap -s'. It
>> will show allocated, reserved, and free VM.

> That sure is useful, thanks. Must have read over it on the manpage as I
> was - at the time - only looking for what -l does.

>> It never "mirrors" anything. However in many cases, the word 'swap' is
>> used synonomously with the entire VM space. It doesn't refer to only
>> the portion used as backing store on disk. For instance, tmpfs is
>> backed in "swap" (meaning all of VM).

> Thanks, that helps. This would explain a lot of strange logs.

> But why? There was indeed a time when the VM size was determined by swap
> and real RAM was only a faster selective mirror, wasn't it?
> So this would only be ancient terminology then?

Yes. In the orginal BSD memory system (including that used by SunOS
4.x), all of VM required backing store. So you had to have at least the
amount of RAM as a swap space. This makes swapping algorithms much
simpler. The VM space can have a dedicated area on disk.

More modern VM architectures (like that used on Solaris) do not require
this one-to-one mapping from disk to VM. Instead, pageable RAM plus
disk allocations sum to form available VM. You can run Solaris without
an active swap file/partition.

>>> If so, bug or feature?
>> I can't say I've seen it.

> Hmmmmm...what's sending the log messages about failing in allocating
> trivial amounts of memory is a non-standard application written by a
> not-alltoo-great ISV, so maybe they are just wrong.

>>> Or is swap still "the VM" and RAM just a "partial mirror/subset" as in
>>> ye olde days?
>> Yup.

> Wait - now this seems to contradict the "It never 'mirrors' anything"
> from above, wouldn't it?

What I'm saying is that the term "swap" is often used as a synonym for
the term "Virtual Memory". I'm not talking about the disk file here.

To avoid confusion, I almost always use the terms "backing store", "swap
file" or "swap partition" to mean the space allocated on the disk,
rather than the term "swap".

> Or are you meaning just the terminology definition swap=VM; because I'm
> talking about actual swap space here, as handled by swap(1M).

Yes.

Careful, even that page is ambiguous. 'swap -l' only deals with active
swap files. 'swap -s' only shows views of the total VM area (it doesn't
break anything down by RAM vs disk).

>>> (I can hardly imagine that, as we had less swap than RAM before my
>>> swap-file; wasn't me who did that, I always do at least (never know when
>>> there's gonna be more RAM) 2xRAM -- but now I'm stuck with it until we
>>> move on to 10.)
>> How did you determine that you had less swap than RAM?

> I know how much RAM I have(4G), and did a
>> swap -l

Swap -l only shows enabled swap files. It's easy for that to be less
than RAM.

-- 
Darren Dunham                                           ddunham@taos.com
Senior Technical Consultant         TAOS            http://www.taos.com/
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >


Relevant Pages

  • Re: swap size for 2gb 2 processors?
    ... out a partition magic run on a 120 gb disk, ... The rule of thumb is 2 * RAM size, in your case that would be 4G. ... price for a swap partition has remained reasonably constant. ...
    (comp.os.linux.misc)
  • Re: [ck] swap prefetching merge plans
    ... After I close some memory demanding aplication that caused huge portion of the memory to be swapped out to disk, the time needed to swith back to firefox or eclipse is really really shorter. ... And software engeneerers and programmers are really working hard to eat all your RAM even if you think that "now you have really much". ... I have so much swap because I am compiling I my packages on tmpfs. ...
    (Linux-Kernel)
  • Re: headsup: swap_pager.c
    ... disk could not keep up with page-in demand. ... "add" another disk while the box is spasticly trying to swap ... around a 200M plus working-set into 32M physical RAM. ... bash me more...I still dont understand why you are trying to fix ...
    (freebsd-arch)
  • Re: why the difference in swap value for vmstat output
    ... > RAM and 56 G of disk swap ... The second is free RAM. ... < This line left intentionally blank to confuse you. ...
    (comp.unix.solaris)
  • Re: why the difference in swap value for vmstat output
    ... > RAM and 56 G of disk swap ... The second is free RAM. ... < This line left intentionally blank to confuse you. ...
    (comp.sys.sun.admin)