blob: 08e67e0f05abf1a21c29e16b4b52c077fafdcae3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/util/alloc.h>
#include <vector>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <sys/resource.h>
using namespace vespalib::alloc;
int main(int argc, char *argv[]) {
if (argc != 4) {
return 77;
}
size_t virt = strtoul(argv[1], nullptr, 0);
size_t blockSize = strtoul(argv[2], nullptr, 0);
size_t numBlocks = strtoul(argv[3], nullptr, 0);
rlimit virtualLimit;
virtualLimit.rlim_cur = virt;
virtualLimit.rlim_max = virt;
assert(setrlimit(RLIMIT_AS, &virtualLimit) == 0);
std::vector<Alloc> mappings;
for (size_t i(0); i < numBlocks; i++) {
mappings.emplace_back(Alloc::allocMMap(blockSize));
memset(mappings.back().get(), 0xa5, mappings.back().size());
}
return 0;
}
|