+ if (physical_mem_bytes == 0) {
+#if defined(__APPLE__)
+ int mib[2] = {CTL_HW, HW_MEMSIZE};
+ size_t length = sizeof(long long);
+ sysctl(mib, 2, &physical_mem_bytes, &length, NULL, 0);
+#else
+ physical_mem_bytes = (long long)sysconf(_SC_PHYS_PAGES) *
+ sysconf(_SC_PAGESIZE);
+#endif
+ }