diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2017-08-24 22:52:37 +0200 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2017-08-24 23:06:26 +0200 |
commit | ba6ea2fd0c0559c6e8d8108bd25252ef7aab68d0 (patch) | |
tree | 5adf6747dd06aa2bb11f4430506da8fc0c2bc272 /configure.ac | |
parent | 8d313963e7680d1dadd7fd6a3c271c2792ffe509 (diff) | |
download | sciteco-ba6ea2fd0c0559c6e8d8108bd25252ef7aab68d0.tar.gz |
fixed memory leaks and memory measurement leaks by removing -fsized-deallocation
* Array allocations were not properly accounted since the compiler
would call the replacement new() which assumes that it would
always be called along with the replacement sized-deletion.
This is not true for array new[] allocations resulting in
a constant increase of memory_usage and unrecoverable situations.
This problem however could be fixed in principle by avoiding
memory counting for arrays or falling back to malloc_usable_size.
* The bigger problem was that some STLs (new_allocator) are broken, calling the
non-sized delete for regular new() calls which could in principle
be matched by sized-delete.
This is also the reason why I had to provide a non-sized
delete replacement, which in reality intoduced memory leaks.
* Since adding checks for the broken compiler versions or a configure-time
check that tries to detect these broken systems seems tedious,
I simply removed that optimization.
* This means we always have to rely on malloc_usable_size() now
for non-SciTECO-object memory measurement.
* Perhaps in the future, there should be an option for allowing
portable measurement at the cost of memory usage, by prefixing
each memory chunk with the chunk size.
Maintainers could then decide to optimize their build for "speed"
at the cost of memory overhead.
* Another solution to this non-ending odyssey might be to introduce
our own allocator, replacing malloc(), and allowing our own
precise measurements.
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 23 |
1 files changed, 0 insertions, 23 deletions
diff --git a/configure.ac b/configure.ac index c341183..032ab10 100644 --- a/configure.ac +++ b/configure.ac @@ -181,29 +181,6 @@ esac AC_CHECK_HEADERS([malloc.h malloc_np.h]) AC_CHECK_FUNCS([malloc_trim malloc_usable_size]) -# Check whether compiler supports global sized deallocations. -# If yes, this will improve the memory limiting fallback -# implementation. -# Once we can depend on C++14, this check is no longer necessary. -AC_CACHE_CHECK([if C++ compiler supports -fsized-deallocation], - [sciteco_cv_sized_deallocation_result], [ - AC_LANG_PUSH(C++) - OLD_CXXFLAGS="$CXXFLAGS" - CXXFLAGS="$CXXFLAGS -fsized-deallocation" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM( - [[#include <new>]], - [[(::operator delete)(0, 256)]] - )], sciteco_cv_sized_deallocation_result=yes, - sciteco_cv_sized_deallocation_result=no) - CXXFLAGS="$OLD_CXXFLAGS" - AC_LANG_POP(C++) -]) -if [[ x$sciteco_cv_sized_deallocation_result = xyes ]]; then - AC_DEFINE(HAVE_SIZED_DEALLOCATION, 1, - [C++ compiler supports -fsized-deallocation]) - CXXFLAGS="$CXXFLAGS -fsized-deallocation" -fi - # # Config options # |