Skip to content

Memory leak/spike during doc-tests #14190

@madonuko

Description

@madonuko

Problem

Both cargo test and cargo test --doc use around (1 + n) GB of memory during doc-test linking, where n is the number of doc-tests. This behaviour can be seen here:

2024-07-04.19-59-38.copy.mp4

The code in question is https://github.com/rpm-rs/rpmspec-rs (master branch or commit 1e57d1d)

Steps

git clone https://github.com/rpm-rs/rpmspec-rs --depth 1
cd rpmspec-rs
cargo test #--doc

Try removing one of the doc-tests. On my machine, for every doc-test I remove, the memory usage drops by 1 GB.

Possible Solution(s)

No response

Notes

Things I have already tried

Extra notes

Notice the memory usage comes from ld (see the video above). However, this only happens with doc-tests; this never happens under cargo check, cargo build and normal tests (i.e. cargo test excluding doc-tests).

Version

cargo 1.79.0 (ffa9cf99a 2024-06-03)
release: 1.79.0
commit-hash: ffa9cf99a594e59032757403d4c780b46dc2c43a
commit-date: 2024-06-03
host: x86_64-unknown-linux-gnu
libgit2: 1.7.2 (sys:0.18.3 vendored)
libcurl: 8.6.0-DEV (sys:0.4.72+curl-8.6.0 vendored ssl:OpenSSL/1.1.1w)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Ultramarine Linux 40.0.0 (lostumbrella) [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-doctestsArea: rustdoc --testC-bugCategory: bugS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions