Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac_BSD_resources underestimates RAM size #4

Closed
aaaaalbert opened this issue May 29, 2015 · 8 comments
Closed

Mac_BSD_resources underestimates RAM size #4

aaaaalbert opened this issue May 29, 2015 · 8 comments
Labels

Comments

@aaaaalbert
Copy link
Contributor

Mac_BSD_resources.py uses sysctl hw.physmem to find the size of RAM. Unfortunately, the info is off by a factor of 4 on a MacBook Pro 8,2 running Mac OS X 10.6.8 on which I'm testing this. (At least we are underestimating the size, so this only hurts the Seattle install, but not the resource donor.)

sysctl hw.memsize gives the correct memory size, 8 GB here.

See also https://discussions.apple.com/thread/1753088?start=0&tstart=0

We should test what the different hw. keys return on a couple of machines, and then decide on a fix.

@aaaaalbert
Copy link
Contributor Author

@fmetzger reports that on his 10.10.5 box, hw.physmem doesn't even exist as a key in sysctl.

@XuefengHuang
Copy link

I tested on my MacBookPro11,1 running Mac OS X 10.10.5.

172-16-29-190:~ Xuefeng$ sysctl hw.memsize
hw.memsize: 8589934592
172-16-29-190:~ Xuefeng$ sysctl hw.physmem
hw.physmem: 2147483648
172-16-29-190:~ Xuefeng$ uname -v
Darwin Kernel Version 14.5.0: Wed Jul 29 02:26:53 PDT 2015; root:xnu-2782.40.9~1/RELEASE_X86_64

@lukpueh
Copy link

lukpueh commented Sep 10, 2015

$ uname -v; sysctl hw.physmem; sysctl hw.memsize;
Darwin Kernel Version 13.4.0: Wed Mar 18 16:20:14 PDT 2015; root:xnu-2422.115.14~1/RELEASE_X86_64
hw.physmem: 2147483648
hw.memsize: 4294967296

@michaelkux
Copy link

$ uname -v; sysctl hw.physmem; sysctl hw.memsize;
Darwin Kernel Version 13.4.0: Wed Mar 18 16:20:14 PDT 2015; root:xnu-2422.115.14~1/RELEASE_X86_64
hw.physmem: 2147483648
hw.memsize: 17179869184

@pooledge
Copy link

$ uname -v; sysctl hw.physmem; sysctl hw.memsize;
Darwin Kernel Version 12.6.0: Wed Mar 18 16:23:48 PDT 2015; root:xnu-2050.48.19~1/RELEASE_X86_64
hw.physmem: 2147483648
hw.memsize: 17179869184

@aaaaalbert
Copy link
Contributor Author

Per PR #6, my proposed fix is to use sysctl hw.memsize.

Thank you all for testing and contibuting!

@durbrow
Copy link

durbrow commented Jun 5, 2019

In case no one figured this out (which they did)...

In sysctl.h,
hw.physmem is documented to be an int (i.e. 32 bit signed int).
hw.memsize is documented to be a uint64_t (i.e. 64 bit unsigned int).

The value you are getting for hw.physmem is the maximum value a 32-bit signed int can hold.

@JustinCappos
Copy link
Contributor

Always nice to get more clarity, even (way) after the fact. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants