diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-02-09 18:22:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-09 18:22:31 +0100 |
commit | 6c6587b5be7ea8ca01bfbfba42b290fb4873ba45 (patch) | |
tree | 67a5dde7b07283d02025add86c64a2a4a6fada67 /staging_vespalib/src/vespa/vespalib/util/malloc_mmap_guard.cpp | |
parent | 5603653ace6fce5bba2bf515685dc1de97a42088 (diff) | |
parent | 5f96af6e4995a7a38445f3d24482baaedeec0668 (diff) |
Merge pull request #21120 from vespa-engine/revert-21119-revert-21118-balder/wire-in-mallopt-control-of-vespamalloc-skeletonv7.541.24
Revert "Revert "Wire in mallopt(in param, int value) interface in vespamalloc and ver…""
Diffstat (limited to 'staging_vespalib/src/vespa/vespalib/util/malloc_mmap_guard.cpp')
-rw-r--r-- | staging_vespalib/src/vespa/vespalib/util/malloc_mmap_guard.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/staging_vespalib/src/vespa/vespalib/util/malloc_mmap_guard.cpp b/staging_vespalib/src/vespa/vespalib/util/malloc_mmap_guard.cpp new file mode 100644 index 00000000000..0ced160fda2 --- /dev/null +++ b/staging_vespalib/src/vespa/vespalib/util/malloc_mmap_guard.cpp @@ -0,0 +1,23 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#include "malloc_mmap_guard.h" +#include <vespa/vespalib/util/size_literals.h> +#include <malloc.h> +#include <limits> +#include <cassert> + +namespace vespalib { + +MallocMmapGuard::MallocMmapGuard(size_t mmapLimit) : + _threadId(std::this_thread::get_id()) +{ + int limit = mmapLimit <= std::numeric_limits<int>::max() ? mmapLimit : std::numeric_limits<int>::max(); + mallopt(M_MMAP_THRESHOLD, limit); +} + +MallocMmapGuard::~MallocMmapGuard() +{ + assert(_threadId == std::this_thread::get_id()); + mallopt(M_MMAP_THRESHOLD, 1_Gi); +} + +} |