From 152397e641e9d1e6a11f80e24f562c4cf2472a2f Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Wed, 8 Mar 2017 12:00:42 +0100 Subject: yet another revision of memory limiting: the glibc mallinfo() approach has been shown to be unacceptably broken, so the fallback implementation has been improved * mallinfo() is not only broken on 64-bit systems but slows things down linearilly to the memory size of the process. E.g. after 500000<%A>, SciTECO will act sluggish! Shutting down afterwards can take minutes... mallinfo() was thus finally discarded as a memory measurement technique. * Evaluating /proc/self/statm? has also been evaluated and discarded because doing this frequently is even slower. * Instead, the fallback implementation has been drastically improved: * If possible use C++14 global sized deallocators, allowing memory measurements across the entire C++ code base with minimal runtime overhead. Since we only depend on C++11, a lengthy Autoconf check had to be introduced. * Use malloc_usable_size() with global non-sized deallocators to measure the approx. memory usage of the entire process (at least the ones done via C++). The cheaper C++11 sized deallocators implemented via SciTECO::Object still have precedence, so this affects Scintilla code only. * With both improvements the test case sciteco -e '<@EU[X^E\a]"^E\a"%a>' is handled sufficiently well now on glibc and performance is much better now. * The jemalloc-specific technique has been removed since it no longer brings any benefits compared to the improved fallback technique. Even the case of using malloc_usable_size() in strict C++ mode is up to 3 times faster. * The new fallback implementation might actually be good enough for Windows as well if some MSVCRT-specific support is added, like using _msize() instead of malloc_usable_size(). This must be tested and benchmarked, so we keep the Windows-specific implementation for the time being. --- src/interface-curses/Makefile.am | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/interface-curses') diff --git a/src/interface-curses/Makefile.am b/src/interface-curses/Makefile.am index e9a2d14..bd61e14 100644 --- a/src/interface-curses/Makefile.am +++ b/src/interface-curses/Makefile.am @@ -4,6 +4,9 @@ AM_CXXFLAGS = -std=c++11 -Wall -Wno-char-subscripts if CLANG AM_CXXFLAGS += -Wno-mismatched-tags endif +if HAVE_SIZED_DEALLOCATION +AM_CXXFLAGS += -fsized-deallocation +endif noinst_LTLIBRARIES = libsciteco-interface.la libsciteco_interface_la_SOURCES = interface-curses.cpp interface-curses.h \ -- cgit v1.2.3