mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 11:32:46 +01:00
Merge #10120: util: Work around (virtual) memory exhaustion on 32-bit w/ glibc
625488a
util: Work around (virtual) memory exhaustion on 32-bit w/ glibc (Wladimir J. van der Laan)
Tree-SHA512: 99b610a8cf9561998af90e16fc19320fddd30c987e8f33325d63df0f56d70235b94d9482e80f28154d4b33a3ecf4961686380c444ec18d1da5e8804a8b6f4de1
This commit is contained in:
parent
a149129656
commit
42d3060568
@ -558,6 +558,14 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/socket.h>]],
|
||||
[ AC_MSG_RESULT(no)]
|
||||
)
|
||||
|
||||
dnl Check for mallopt(M_ARENA_MAX) (to set glibc arenas)
|
||||
AC_MSG_CHECKING(for mallopt M_ARENA_MAX)
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <malloc.h>]],
|
||||
[[ mallopt(M_ARENA_MAX, 1); ]])],
|
||||
[ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_MALLOPT_ARENA_MAX, 1,[Define this symbol if you have mallopt with M_ARENA_MAX]) ],
|
||||
[ AC_MSG_RESULT(no)]
|
||||
)
|
||||
|
||||
AC_MSG_CHECKING([for visibility attribute])
|
||||
AC_LINK_IFELSE([AC_LANG_SOURCE([
|
||||
int foo_def( void ) __attribute__((visibility("default")));
|
||||
|
14
src/util.cpp
14
src/util.cpp
@ -75,6 +75,10 @@
|
||||
#include <sys/prctl.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MALLOPT_ARENA_MAX
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
#include <boost/algorithm/string/case_conv.hpp> // for to_lower()
|
||||
#include <boost/algorithm/string/join.hpp>
|
||||
#include <boost/algorithm/string/predicate.hpp> // for startswith() and endswith()
|
||||
@ -903,6 +907,16 @@ std::string GetThreadName()
|
||||
|
||||
void SetupEnvironment()
|
||||
{
|
||||
#ifdef HAVE_MALLOPT_ARENA_MAX
|
||||
// glibc-specific: On 32-bit systems set the number of arenas to 1.
|
||||
// By default, since glibc 2.10, the C library will create up to two heap
|
||||
// arenas per core. This is known to cause excessive virtual address space
|
||||
// usage in our usage. Work around it by setting the maximum number of
|
||||
// arenas to 1.
|
||||
if (sizeof(void*) == 4) {
|
||||
mallopt(M_ARENA_MAX, 1);
|
||||
}
|
||||
#endif
|
||||
// On most POSIX systems (e.g. Linux, but not BSD) the environment's locale
|
||||
// may be invalid, in which case the "C" locale is used as fallback.
|
||||
#if !defined(WIN32) && !defined(MAC_OSX) && !defined(__FreeBSD__) && !defined(__OpenBSD__)
|
||||
|
Loading…
Reference in New Issue
Block a user