I made "memlimit", a very simple tool to limit the amount of memory a program can use (and kill it if it goes over the limit)
I created this tool after having tried to bisect some rustc bugs a while ago, and discovering that there wasn't an easy way to limit the amount of memory a program can use in a multi-platform way (I'm working on Windows at home). There are a bunch of methods to do that on Linux, but I feel like they're a bit contrived and part of a greater ecosystem of limits that may not really be easy to use in the context of cargo-bisect-rustc.
With this program, you can specify the maximum amount of memory a command can use before it gets killed (of course, if it doesn't go over that limit, then everything goes normally). If needed, you can follow children too and assert that the sum of all memory consumed by all of them doesn't go over the limit. You can also switch between RSS memory and virtual memory, if needed. So, for example:
$ memlimit 16GiB -c cargo install ripgrep --force
This will:
- set a limit of 16GiB (gibibytes, 16 x 1024 x 1024 x 1024 bytes)
- with
-c, follow all children spawned by the initial program and sum up their memory usage - monitor the command
cargo install ripgrep --force
I know this isn't a really impressive or important tool, but I felt there wasn't an easy-to-use multiplatform tool to do this. It's very small and doesn't have a lot of features, so I'm super open to criticism and suggestions!