Determine physical mem size programmatically on OSX

前端 未结 4 1210
天命终不由人
天命终不由人 2020-12-29 14:33

We\'re trying to find out how much physical memory is installed in a machine running Mac OS X. We\'ve found the BSD function sysctl(). The problem is this function wants to

4条回答
  •  难免孤独
    2020-12-29 15:13

    Did you try googling?

    This seems to be the answer: http://lists.apple.com/archives/scitech/2005/Aug/msg00004.html

    sysctl() does work, you just need to fetch hw.memsize instead of hw.physmem. hw.memsize will give you a uint64_t, so no 32 bit problem.

提交回复
热议问题