Skip to content

Commit d45520e

Browse files
committed
[FIX] memory prediction on macOS
1 parent c4a4f6c commit d45520e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/misc.hpp

+10
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <unistd.h>
2626
#include <type_traits>
2727
#include <forward_list>
28+
#include <sys/sysctl.h>
2829

2930
#include <seqan/basic.h>
3031
#include <seqan/sequence.h>
@@ -575,9 +576,18 @@ unsigned long long dirSize(char const * dirName)
575576

576577
unsigned long long getTotalSystemMemory()
577578
{
579+
#if defined(__APPLE__)
580+
uint64_t mem;
581+
size_t len = sizeof(mem);
582+
sysctlbyname("hw.memsize", &mem, &len, NULL, 0);
583+
return mem;
584+
#elif defined(__unix__)
578585
long pages = sysconf(_SC_PHYS_PAGES);
579586
long page_size = sysconf(_SC_PAGE_SIZE);
580587
return pages * page_size;
588+
#else
589+
# error "no way to get phys pages"
590+
#endif
581591
}
582592

583593

0 commit comments

Comments
 (0)