determining size of physical memory

Jim Kohli kohli at gemed
Sat Dec 29 10:35:36 AEST 1990


In article <7325 at plains.NoDak.edu>, bakke at plains.NoDak.edu (Jeffrey P. Bakke)
writes:
 >In article <1990Dec27.202715.27688 at Neon.Stanford.EDU>, hitt at Neon.Stanford.EDU (Daniel Hitt) writes:
 >> Is there a standard UNIX program or system call that determines
 >> the size of the physical memory of the machine on which it is
 >> running?
 >> 
 >> I'd like to be able to do this on Ultrix, SunOS, and the NeXT OS,
 >> and possibly HP-UX.
 >
 >Well, I'm not positive that this is the best way or the that it will work
 >correctly under all instances but if you have read access to the /dev/mem
 >(or /dev/kmem) you might just try
 >'wc -c < /dev/mem' using the word count program to count the number of
 >bytes.  I've found on most systems that it will return the correct physical
 >memory size (not swap space though).  
 >
 While in theory this should work, there seems
 to be a problem with SunOS 4.01-- the /dev/mem
 driver gives you an early EOF indicating fewer
 bytes than there really are.

 I don't know if it's fixed in SunOS 4.1.

 There's approach also presents the problem of
 needing to run as root, since /dev/mem is (or SHOULD BE)
 read-protected.  It would be nice if there was a way to
 find out how much physical memory there is in a Sun without
 rebooting.

 Jim Kohli



More information about the Comp.unix.questions mailing list