Changeset: 3bb357e5c047 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3bb357e5c047
Modified Files:
gdk/gdk_utils.mx
Branch: Apr2011
Log Message:
memory detection: cap detected memory on 32-bits platforms
When the detected memory exceeds what a size_t can store, cap the memory
size to that max, before computing the number of pages available.
Our buildx86macosx machine has 8GiB of memory, but in 32-bits mode this
meant an overflow, and hence 0GiB detected. Since the default branch no
longer "respects" rlimits, the problem became visible there.
diffs (29 lines):
diff --git a/gdk/gdk_utils.mx b/gdk/gdk_utils.mx
--- a/gdk/gdk_utils.mx
+++ b/gdk/gdk_utils.mx
@@ -523,6 +523,12 @@
mib[0] = CTL_HW;
mib[1] = HW_MEMSIZE;
sysctl(mib, 2, &size, &len, NULL, 0);
+# ifdef SIZEOF_SIZE_T == SIZEOF_INT
+ /* we can have more memory than a size_t can handle on a 32-bits
+ * platform, so trim it down, if that is the case */
+ if (size > (size_t)-1)
+ size = (size_t)-1;
+# endif
_MT_npages = size / _MT_pagesize;
}
#elif defined(HAVE_SYS_SYSCTL_H) && defined (HW_PHYSMEM64)
@@ -537,6 +543,12 @@
mib[0] = CTL_HW;
mib[1] = HW_PHYSMEM64;
sysctl(mib, 2, &size, &len, NULL, 0);
+# ifdef SIZEOF_SIZE_T == SIZEOF_INT
+ /* we can have more memory than a size_t can handle on a 32-bits
+ * platform, so trim it down, if that is the case */
+ if (size > (size_t)-1)
+ size = (size_t)-1;
+# endif
_MT_npages = size / _MT_pagesize;
}
#elif defined(HAVE_SYSCONF) && defined(_SC_PHYS_PAGES)
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list