Re: Why does code fail to find *exact* amouut of RAM??
From: Kasper Dupont (kasperd_at_daimi.au.dk)
Date: 09/02/03
- Next message: Eric Gisin: "Re: determine interactive or batch mode"
- Previous message: Alan Coopersmith: "Re: Solaris 9 Companion CD (freeware) announcement"
- In reply to: Gavin Maltby: "Re: Why does code fail to find *exact* amouut of RAM??"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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.
- Next message: Eric Gisin: "Re: determine interactive or batch mode"
- Previous message: Alan Coopersmith: "Re: Solaris 9 Companion CD (freeware) announcement"
- In reply to: Gavin Maltby: "Re: Why does code fail to find *exact* amouut of RAM??"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|