Re: Why does code fail to find *exact* amouut of RAM??

From: Kasper Dupont (kasperd_at_daimi.au.dk)
Date: 09/02/03


Date: Tue, 02 Sep 2003 18:16:52 +0200

Gavin Maltby wrote:
>
> viro@parcelfarce.linux.theplanet.co.uk wrote:
>
> >>So it is quite clear the physical memory reported by a system is
> >>always exact in the case of the commercial operating systems, but
> >>never so on the free ones.
>
> For the record, Solaris/SPARC (all I checked) does report the installed
> physical memory as originally reported by OBP and perhaps later
> modified by DR operations that introduce or remove memory.
>
> > You do realize, of course, that about the only use of such information
> > is sysinfo(8)? For one thing, kernel code and data structures take
> > some space. Moreover, programs do not run alone and knowing the amount
> > of RAM in the system is fairly pointless as far as individual programs
> > count. If you need some part of address space in core (e.g. for RT-ish
> > stuff), you'd better use mlock(2) and it will tell you if it fails...
>
> Not sure I agree. A database, for instance, could try to size it's
> SGA (for Oracle, dunno what others call it) dynamically within
> physical memory.

In that case the value returned by Linux is more usable than the
total amount of physical memory. Of course still an application
shouldn't try to allocate that much, for performance it is better
to keep your executable, libraries, and some other stuff in
memory all the time.

> Algorithms based on failed allocation attempts
> seem messy, especially if you want them to work on system with
> 256MB of memory up to those with hundreds or thousands of GB.

It is going to be inefficient as well, because allocations will
first fail when you start to run out of swap, and your performance
will be bad because of trashing when trying to use too much
memory. And that is even the best case, in the worst case your
allocations will suceed, and eventually you get killed when the
memory actually runs out.

> But it would be better of starting with _SC_AVPHYS_PAGES rather
> than _SC_PHYS_PAGES. sort uses that for it's -S option.

I don't know about other systems, but on Linux _SC_AVPHYS_PAGES
would be pretty useless for those purposes. It returns only the
free memory, which can be pretty small because of caching. In
some cases you want your programs to allocate enough to cause
caches to shrink and maybe even cause other programs to get
swapped out.

-- 
Kasper Dupont -- der bruger for meget tid paa usenet.
For sending spam use mailto:aaarep@daimi.au.dk
Their business was zero and it was shrinking.


Relevant Pages

  • Re: Another Memory question
    ... since my SP3 clients all report that value, ... I waited for some clients to finish an inventory cycle. ... inventoried clients did not have a total phsyical memory. ... total physical memory in the v_gs_computer_system view. ...
    (microsoft.public.sms.inventory)
  • relic Have you learned how to post yet?
    ... As you have a selective memory, here is the source code for you. ... applications with a 4 GB virtual address space. ... that run on computers with more than 2 GB of physical memory. ... Address Windowing Extensions (AWE) enables applications to address more = ...
    (alt.os.windows-xp)
  • [PATCH] Physical Memory Management [1/1]
    ... PMM allows allocation of continiuous blocks of physical memory. ... * space programs may desire to allocate areas of different types. ...
    (Linux-Kernel)
  • Re: RAM
    ... For applications that are I/O-intensive, ... The 4GT RAM Tuning feature increases the memory ... more than 2 GB of physical memory. ... VirtualAlloc function. ...
    (alt.os.windows-xp)
  • Re: 4GB Physical Memory Support
    ... Whether or not 4GB of physical memory is necessary is a moot point, the question remains why changing the page file size altered the amount of physical memory recognized by Windows. ... However, keep in mind that the PCI Hole exists as a result of addressing done by the BIOS, not by Windows. ...
    (microsoft.public.windowsxp.hardware)