Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.unix.questions Subject: Re: determining size of physical memory Keywords: core, physical memory, size of core Message-ID: <10893@jpl-devvax.JPL.NASA.GOV> Date: 3 Jan 91 00:23:43 GMT References: <1990Dec27.202715.27688@Neon.Stanford.EDU> <1368@prcrs.UUCP> <7325@plains.NoDak.edu> <1369@prcrs.UUCP> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 42 In article <1369@prcrs.UUCP> wrwalke@prcrs.UUCP (William Walker) writes: : In article <7325@plains.NoDak.edu>, bakke@plains.NoDak.edu (Jeffrey P. Bakke) writes: : > In article <1990Dec27.202715.27688@Neon.Stanford.EDU>, hitt@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. : > : > '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). : : or how about ... : : dd if=/dev/mem of=/dev/null bs=1024 : : this one is a try-at-you-own-risc solution, but it : works on vax ultrix 3.1 and s800 hp-ux 7.0. On a Sun you can derive it from the stuff the adb -k command prints out. The following Perl script does this: #!/usr/bin/perl $ENV{'PATH'} = '/bin:/usr/bin'; unless (open(ADB,"-|")) { open(STDIN,'/dev/null'); exec 'adb', '-k', '/vmunix', '/dev/mem'; exit 1; } $_ = ; $_ = unless /^phys/; close ADB; ($foo,$size) = split; $size = (int(hex($size) / 0x100) + 1) * 2; print $size,"\n"; Larry Wall lwall@jpl-devvax.jpl.nasa.gov