Something like the following should use the power of sysctl. physmem and usermem in place of realmem may be of use too. Just wish I knew proper values nad logic to tweak kern.ipc.shmmax and similar paramaters. int realmem; char* realmem_mib_name = "hw.realmem"; return(sysctlbyname(usermem_mib_name, &realmem, &len, 0, 0))