diff --git a/src/main_utils.cpp b/src/main_utils.cpp
index 05714cc5b1f90929da976bce950343f339c0280c..22cc39af5f56074073131fcadae50b1410706864 100644
--- a/src/main_utils.cpp
+++ b/src/main_utils.cpp
@@ -18,25 +18,29 @@
 using namespace std;
 
 /*
- * Use this function to get the amount of RAM on the machine (used or not).
+ * Use this function to get the amount of RAM in GB on the machine (used or not).
  * Aim is to make sure that ROCK can run on the current machine with the requirements that the user gave.
  */
 unsigned long getNodePhysMemory() {
-#ifdef __linux__
-    return sysconf(_SC_PHYS_PAGES)*sysconf(_SC_PAGESIZE)/1024/1024/1024;
+    uint64_t mem = 0;
+
+#if defined(_SC_PHYS_PAGES) && defined(_SC_PAGESIZE)
+    mem = sysconf(_SC_PHYS_PAGES);
+    mem *= sysconf(_SC_PAGESIZE);
+    mem /=  1 * 1024 * 1024 * 1024;
 #elif __APPLE__
-    int64_t mem;
     size_t len = sizeof(mem);
-    int ret=sysctlbyname("hw.memsize", (void*) &mem, &len, NULL,0); // total RAM is given in bytes; so convert it to MB.*/
+    int ret=sysctlbyname("hw.memsize", (void*) &mem, &len, NULL,0);
     if (ret==-1) {
         cout<<"Couldn't determine how much RAM is usable on your system."<<errno<<endl;
-        return errno;
+	mem=0;
     }
-    return mem/1024/1024/1024;
+    mem /=  1 * 1024 * 1024 * 1024;
 #else
     cout<<"ROCK has not been tested on this operating system, please contact author."<<endl;
-    return unknown_os;
 #endif
+
+    return (unsigned long)mem;
 }
 
 
diff --git a/src/rock.cpp b/src/rock.cpp
index 7430dd6af0991d96a064ba20ed64ea01f2c92307..e51396554aa916984819ea5a34cb7f0bf3a5ebbf 100644
--- a/src/rock.cpp
+++ b/src/rock.cpp
@@ -29,7 +29,6 @@
 
 
 
-#define unknown_os 1
 #define defaultGRPMAXSize 1 //(in gigabytes) Default maximum size of srp structure but of course this size depends of the number of reads we are processing.
                             // 1 GB is enough to store approx 82 millions of reads (must take into account memory needed for stl containers).
                             // This constant is used only if you use rock's default behavior (use 90% of the machine's RAM).
@@ -145,7 +144,7 @@ int main(int argc,char * argv[]) {
     parms.lambda=0;
     parms.filter_size=getNodePhysMemory()/100*90-defaultGRPMAXSize; // Prefer not to use all the machine's memory
 
-    if (parms.filter_size==unknown_os) return EXIT_FAILURE;
+    if (parms.filter_size==0) return EXIT_FAILURE;
     while((i = getopt(argc, argv, "i:o:l:k:c:C:g:n:")) != -1) {
         switch(i) {
             case 'i':