cargo-outdated: Memory usage is high, resulting in Out of memory OS kill

When running cargo outdated on a repository with many small crates (46), this error appears after a while:

cargo outdated
[1]    5557 killed     cargo outdated

The system is Ubuntu 16.04 with 8 GB physical memory. Investigating with:

dmesg | less

gives:

[22541.218190] Out of memory: Kill process 5557 (cargo-outdated) score 611 or sacrifice child
[22541.218196] Killed process 5557 (cargo-outdated) total-vm:8599764kB, anon-rss:5518604kB, file-rss:4kB, shmem-rss:0kB
[22541.529600] oom_reaper: reaped process 5557 (cargo-outdated), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB

I haven’t checked code, but if it’s trying to compile the whole repo in /tmp which is mounted on my RAM, perhaps that explains it.

Can see from this graph that the memory usage (green) spikes before it’s killed:

memory

A proposed fix is to take in a parameter for the temporary location to compile. Maybe there’s some parts of the code that can be memory optimized as well.

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Comments: 18 (6 by maintainers)

Most upvoted comments

I’m sorry that happened 😞 But thank you for providing that project as this really helps and I was able to reproduce the unbounded memory growth which makes me thing it’s some cyclic dependency.

I have a (not open source) workspace with a total of 766 transitive dependencies and cargo outdated eventually consumes all my RAM and dies. This is on Linux, rustc 1.44, and cargo-outdated v0.9.11.

It still happens on the workspace mentioned here with rustc 1.70 and cargo-outdated 0.13.1

Btw, are you using a workspace, where the root crate is non-virtual (aka has source code)?

edit: With version 0.8.0, in my workspace that has 60 member crates, on my Windows box with 16 gigs of memory, it just hangs.

ran for 3 hours, using 13 gb memory before I cancelled it

image

Interrupted it to show how long it was running:

[16:32:52] autex_master master
$ time cargo outdated -w

real    179m8.593s
user    0m0.015s
sys     0m0.141s

[19:32:14] autex_master master
with `--depth 8` specified it ends in 9 minutes, but says everything is up to date
$ time cargo outdated -p will --depth 8
All dependencies are up to date, yay!

real    9m0.528s
user    0m0.000s
sys     0m0.062s

Just wanted to note that it works without such problems here on 35 root dependencies (at 340 dependencies to build). With max of 119MB heap, taking 1 second.