It seems memory_pressure under no pressure to report the right numbers

So today I wasted a bit of time trying to figure out why the memory_pressure tool in Mavericks was giving me some surprising news:

‘The system has 2147483648 (524288 pages with a page size of 4096).’

This machine is supposed to have 8GiB. So what gives? We peek into the sauce to find they’ve used this:

phys_mem = read_sysctl_int(“hw.physmem”);

And what do we see in man sysctlbyname? This:


             The bytes of physical memory represented by a 32-bit integer (for backward compatibility). Use HW_MEMSIZE instead.

Sure enough, hw.memsize is the one we want – tells me I have 8589934592 bytes. That’s better.

My current gig has me spending a fair bit of time looking at stuff on and I must say I’m actually a bit surprised by the number of not so great things I’ve encountered. It seems like they might benefit from more code review rigour. Then again, their revenues and customer satisfaction numbers don’t really bear that out I guess, so fuck it.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s