Skip to content

Instantly share code, notes, and snippets.

@yugr
yugr / gist:270a376d323045df82d0cf462207fac8
Created July 23, 2023 09:40
Using cgroups to limit Memory usage
Based on https://www.flamingbytes.com/blog/cgroups-limit-memory/
Install prerequisites:
$ apt install libcgroup libcgroup-tools
Create new group:
$ cgcreate -g memory:/memlimited
Set limit:
$ echo 32G > /sys/fs/cgroup/memory/memlimited/memory.limit_in_bytes
@yugr
yugr / gist:4db31883cda2c2513e2705d5b3b475cb
Last active April 9, 2023 15:44
Example min implementation
template<typename T>
const T &min(const T &a, const T &b) {
return b < a ? b : a;
}
@yugr
yugr / Using Msan
Last active September 23, 2023 16:13
# Build llvm
cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
-DLLVM_USE_SANITIZER="MemoryWithOrigins"
-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \
-DCMAKE_BUILD_TYPE=RelWithDebInfo -G Ninja \
-S runtimes -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" \
path/to/llvm
ninja -j32 install-cxx install-cxxabi