Enable memory unmapping by default

Issue #152 (bdwgc).

* CMakeLists.txt (enable_munmap): New OPTION (on by default).
* CMakeLists.txt [enable_munmap] (USE_MMAP, USE_MUNMAP): Define macro.
* CMakeLists.txt [enable_checksums && enable_munmap): Issue MESSAGE
that CHECKSUMS is not compatible with USE_MUNMAP.
* configure.ac (AC_ARG_ENABLE(munmap)): Update the help message.
* configure.ac [$enable_munmap=""]: Treat as enable_munmap="yes".
* configure.ac [$MUNMAP_THRESHOLD=""]: Treat as MUNMAP_THRESHOLD="yes".
* doc/README.win32 (GNU Tools): Note about "--disable-munmap" option.
* doc/debugging.md (Unexpectedly Large Heap): Remove advice about
"--enable-munmap" option.
This commit is contained in:
Ivan Maidanski
2018-04-14 09:26:03 +03:00
parent 9b9b7e368c
commit 1aabce0f9f
4 changed files with 13 additions and 10 deletions
+6 -1
View File
@@ -192,6 +192,11 @@ IF(enable_redirect_malloc)
ADD_DEFINITIONS("-DGC_USE_DLOPEN_WRAP")
ENDIF(enable_redirect_malloc)
OPTION(enable_munmap "Return page to the OS if empty for N collections" ON)
IF(enable_munmap)
ADD_DEFINITIONS("-DUSE_MMAP -DUSE_MUNMAP")
ENDIF(enable_munmap)
OPTION(enable_large_config "Optimize for large heap or root set" NO)
IF(enable_large_config)
ADD_DEFINITIONS("-DLARGE_CONFIG")
@@ -204,7 +209,7 @@ ENDIF(enable_gc_assertions)
OPTION(enable_checksums "Report erroneously cleared dirty bits" NO)
IF(enable_checksums)
IF(enable_threads)
IF(enable_munmap OR enable_threads)
MESSAGE("CHECKSUMS not compatible with USE_MUNMAP or threads")
ENDIF(enable_threads)
ADD_DEFINITIONS("-DCHECKSUMS")
+5 -5
View File
@@ -898,9 +898,10 @@ fi
AC_ARG_ENABLE(munmap,
[AC_HELP_STRING([--enable-munmap=N],
[return page to the os if empty for N collections])],
[Return page to the OS if empty for N collections
(default: 6)])],
MUNMAP_THRESHOLD=$enableval)
if test x$enable_munmap != x -a x$enable_munmap != xno; then
if test x$enable_munmap != xno; then
AC_DEFINE([USE_MMAP], 1,
[Define to use mmap instead of sbrk to expand the heap.])
AH_TEMPLATE([USE_WINALLOC],
@@ -909,7 +910,7 @@ if test x$enable_munmap != x -a x$enable_munmap != xno; then
AC_DEFINE([USE_MUNMAP], 1,
[Define to return memory to OS with munmap calls
(see doc/README.macros).])
if test "${MUNMAP_THRESHOLD}" = "yes"; then
if test x$MUNMAP_THRESHOLD = x -o x$MUNMAP_THRESHOLD = xyes; then
MUNMAP_THRESHOLD=6
fi
AC_DEFINE_UNQUOTED([MUNMAP_THRESHOLD], [${MUNMAP_THRESHOLD}],
@@ -928,8 +929,7 @@ AC_ARG_ENABLE(checksums,
substantial performance cost; use only for debugging
of the incremental collector])])
if test x$enable_checksums = xyes; then
if test x$enable_munmap != x -a x$enable_munmap != xno \
-o x$THREADS != xnone; then
if test x$enable_munmap != xno -o x$THREADS != xnone; then
AC_MSG_ERROR([CHECKSUMS not compatible with USE_MUNMAP or threads])
fi
AC_DEFINE([CHECKSUMS], 1,
+1 -1
View File
@@ -71,7 +71,7 @@ configure (this will instruct make to compile with -D GC_DLL).
Parallel marker is enabled by default; it could be disabled by
"--disable-parallel-mark" option.
Memory unmapping could be enabled via "--enable-munmap".
Memory unmapping could be turned off by "--disable-munmap" option.
Borland Tools
-------------
+1 -3
View File
@@ -125,9 +125,7 @@ Unexpected heap growth can be due to one of the following:
symptom is that GC_dump() shows much of the heap as black-listed.
3. Heap fragmentation. This should never result in unbounded growth, but
it may account for larger heaps. This is most commonly caused by allocation
of large objects. On some platforms it can be reduced by building with
`-DUSE_MUNMAP`, which will cause the collector to unmap memory corresponding
to pages that have not been recently used.
of large objects.
4. Per object overhead. This is usually a relatively minor effect, but
it may be worth considering. If the collector recognizes interior pointers,
object sizes are increased, so that one-past-the-end pointers are correctly