Skip to content

Commit

Permalink
[FIX] memory prediction on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
h-2 committed Jun 29, 2017
1 parent c4a4f6c commit d45520e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/misc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <unistd.h>
#include <type_traits>
#include <forward_list>
#include <sys/sysctl.h>

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

unsigned long long getTotalSystemMemory()
{
#if defined(__APPLE__)
uint64_t mem;
size_t len = sizeof(mem);
sysctlbyname("hw.memsize", &mem, &len, NULL, 0);
return mem;
#elif defined(__unix__)
long pages = sysconf(_SC_PHYS_PAGES);
long page_size = sysconf(_SC_PAGE_SIZE);
return pages * page_size;
#else
# error "no way to get phys pages"
#endif
}


Expand Down

0 comments on commit d45520e

Please sign in to comment.