diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2017-03-06 17:34:45 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2017-03-06 22:09:17 +0100 |
commit | a2e52ca49c6a5495f134648e91647008dca4a742 (patch) | |
tree | e7b8cbed3a785d9e7db50b38fad7720b54ff058e /configure.ac | |
parent | d9e384e47f44ceadd5738cfaf885aa10260d1923 (diff) | |
download | sciteco-a2e52ca49c6a5495f134648e91647008dca4a742.tar.gz |
roll back to the old mallinfo() implementation of memory limiting on Linux and added a FreeBSD/jemalloc-specific implementation
* largely reverts 39cfc573, but leaves in minor and documentation
changes.
* further experimentation of memory limiting using malloc() wrapping
has shown additional problems, like dlsym() calling malloc-functions,
further reducing the implementation to glibc-specific means.
This means there had been no implementation for FreeBSD and checks
would have to rely on undocumented internal implementation details
of different libcs, which is not a good thing.
* Other problems have been identified, like having to wrap calloc(),
guarding against underruns and multi-thread safety had been identified
but could be worked around.
* A technique by calculating the memory usage as sbrk(0) - &end
has been shown to be effective enough, at least on glibc.
However even on glibc it has shortcomings since malloc() will
somtimes use mmap() for allocations and the technique
relies on implementation details of the libc.
Furthermore another malloc_trim(0) had to be added to the error
recovery in interactive mode, since glibc does not adjust the program break
automatically (to avoid syscalls I presume).
* On FreeBSD/jemalloc, the sbrk(0) method totally fails because jemalloc
exclusively allocates via mmap() -> that solution was discarded as well.
* Since all evaluated techniques turn out to be highly platform
specific, I reverted to the simple and stable platform-specific
mallinfo() API on Linux.
* On FreeBSD/jemalloc, it's possible to use mallctl("stats.allocated")
for the same purpose - so it works there, too now.
It's slower than the other techniques, though.
* A lengthy discussion has been added to memory.cpp, so that we
do not repeat the previous mistakes.
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/configure.ac b/configure.ac index dc8b1d2..e3fd728 100644 --- a/configure.ac +++ b/configure.ac @@ -163,22 +163,24 @@ AC_CHECK_FUNCS([memset setlocale strchr strrchr fstat], , [ # and UNIXoid systems, so that G_OS_UNIX is sufficient # to test for them. # FIXME: Perhaps it would be more elegant to check whether -# glib defines G_OS_UNIX||G_OS_HAIKU instead... +# glib defines G_OS_UNIX || G_OS_HAIKU instead... case $host in *-*-linux* | *-*-*bsd* | *-*-darwin* | *-*-cygwin* | *-*-haiku*) - AC_SEARCH_LIBS([dlsym], [dl], , [ - AC_MSG_ERROR([Required function dlsym() not found!]) - ]) - AC_CHECK_FUNCS([realpath fchown dup dup2 dlsym], , [ + AC_CHECK_FUNCS([realpath fchown dup dup2], , [ AC_MSG_ERROR([Missing libc function]) ]) ;; esac -# Check for optional libc features. -# Will probably only be found on Linux/glibc or BSD. -AC_CHECK_HEADERS([malloc.h malloc_np.h]) -AC_CHECK_FUNCS([malloc_trim malloc_usable_size]) +# Check for optional glibc features. +# Will probably only be found on Linux/glibc. +AC_CHECK_HEADERS([malloc.h]) +AC_CHECK_FUNCS([malloc_trim mallinfo]) + +# jemalloc-specific functions. +# Will probably only be foudn on FreeBSD. +AC_CHECK_HEADERS([malloc_np.h]) +AC_CHECK_FUNCS([mallctlnametomib mallctlbymib]) # # Config options |