Description
Problem
When cargo invokes rustc
or rustdoc
(via cargo doc
or cargo build
, the child process's entire stdout is kept in memory. This can lead to the system's memory being completely exhausted if rustc
or rustdoc
produce a lot of output (e.g. when RUST_LOG
is set).
Steps
- Create a file called
yes.sh
containing the stringyes
(If theyes
program is unavailable, replace it with a script that endlessly writes to stdout) - Run
chmod +x ./yes.sh
- Run
RUSTC=./yes.sh cargo build
in any crate directory. - Observe that cargo's memory usage quickly rises to consume all available memory.
Possible Solution(s)
cargo should clear each line of a child command's stdout from memory once it has been printed, since it won't be needed again.
Notes
Output of cargo version
: cargo 1.29.0 (524a578d7 2018-08-05)
Tested on Arch Linux - this should be reproducible on any Linux-based system.