提交 3e109d83 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!95 memory:optimize "Memory Fragmentation"

Merge pull request !95 from 赵鹏元/master
......@@ -17,8 +17,29 @@
#include "anbox/daemon.h"
#include "anbox/utils.h"
#include <malloc.h>
int main(int argc, char **argv) {
/* Note: Nowadays, glibc uses a dynamic mmap threshold by
default. The initial value of the threshold is 128*1024, but
when blocks larger than the current threshold and less than or
equal to DEFAULT_MMAP_THRESHOLD_MAX are freed, the threshold
is adjusted upward to the size of the freed block. When
dynamic mmap thresholding is in effect, the threshold for
trimming the heap is also dynamically adjusted to be twice the
dynamic mmap threshold. Dynamic adjustment of the mmap
threshold is disabled if any of the M_TRIM_THRESHOLD,
M_TOP_PAD, M_MMAP_THRESHOLD, or M_MMAP_MAX parameters is set. */
constexpr int KILO_BYTES = 1024;
constexpr int DEFAULT_THRESHOLD = 128 * KILO_BYTES;
constexpr int DEFAULT_TOP_PAD = 128 * KILO_BYTES;
constexpr int DEFAULT_MMAP_MAX = 64 * KILO_BYTES;
mallopt(M_ARENA_MAX, 2);
mallopt(M_MMAP_THRESHOLD, DEFAULT_THRESHOLD);
mallopt(M_TRIM_THRESHOLD, DEFAULT_THRESHOLD);
mallopt(M_TOP_PAD, DEFAULT_TOP_PAD);
mallopt(M_MMAP_MAX, DEFAULT_MMAP_MAX);
anbox::Daemon daemon;
return daemon.Run(anbox::utils::collect_arguments(argc, argv));
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册