Re: API to get installed RAM
Re: API to get installed RAM
- Subject: Re: API to get installed RAM
- From: Quinn <email@hidden>
- Date: Mon, 25 Apr 2005 13:48:52 +0100
At 11:36 +0100 25/4/05, Andy Cave wrote:
That's not documented on your web site
(gestaltPhysicalRAMSizeInMegabytes) - what's the selector for it?
It was new with Mac OS X 10.3 (it may also be in 'Smeagol', the Mac
OS X 10.2.x build that supported the G5). It's in the Mac OS X
10.3.x headers, but if you don't have them handy here's an excerpt.
/*
Because some PowerPC machines now support very large physical memory
capacities, including some above the maximum value which can held in
a 32 bit quantity, there is now a new selector,
gestaltPhysicalRAMSizeInMegabytes, which returns the size of
physical memory scaled in megabytes. It is recommended that code
transition to using this new selector if it wants to get a useful
value for the amount of physical memory on the system. Code can
also use the sysctl() and sysctlbyname() BSD calls to get these
kinds of values.
For compatability with code which assumed that the value in returned by
the gestaltPhysicalRAMSize selector would be a signed quantity of
bytes, this selector will now return 2 gigabytes-1 ( LONG_MAX ) if
the system has 2 gigabytes of physical memory or more.
*/
enum {
gestaltPhysicalRAMSize = 'ram ' /* physical RAM size, in bytes */
};
enum {
gestaltPhysicalRAMSizeInMegabytes = 'ramm' /* physical RAM size,
scaled in megabytes */
};
You know it would also be really useful to have a gestalt for 'free
physical memory available' for Carbon...
Actually, I disagree. On a Mac OS X system that's working properly,
it would always return some value close to zero (except shortly after
boot). That's because, on Mac OS X's, the Unified Buffer Cache (UBC)
uses all of physical memory (except that wired for kernel use) as a
VM/disk cache. It keeps caching data until physical memory is short,
after which it throws data away to maintain a reasonable pool of free
physical memory. Thus, the value you'd get back would represent that
threshold, and would be pretty meaningless as an indication of the
memory pressure on the machine.
You can see this in Activity Monitor. In the System Memory tab, the
green slice of the pie is the free memory, and it generally sits
around a constant value (15 MB on my machine).
S+E
--
Quinn "The Eskimo!" <http://www.apple.com/developer/>
Apple Developer Technical Support * Networking, Communications, Hardware
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden