rust-lang / rust-lang/git2-rs

clone a Repo, The memory has increased from 1m to 20m and will not be released

Open
#695 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
2.1k
Forks
450
Avg merge
11m
Merged PRs (30d)
1

Description

I use this code to clone repo, The memory has increased from 1m to >20m and more。And will not be released

fn clone(){

    let mut callbacks = RemoteCallbacks::new();

    callbacks.credentials(|_url, username_from_url, _allowed_types| {
        Cred::userpass_plaintext("abc","abcd)
    });

    // Prepare fetch options.
    let mut fo = git2::FetchOptions::new();
    fo.remote_callbacks(callbacks);

    // Prepare builder.
    let mut builder = git2::build::RepoBuilder::new();
    builder.fetch_options(fo);

    let r= builder.clone(
        "http://xxxx.git",
        Path::new("/code-analyse/"),
    );

    match r{
        Ok(repo) => {println!("ok") }
        Err(e) => {println!("{}",e)}
    }
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported growth in the shown clone function using git2::build::RepoBuilder::clone and monitor memory before and after the operation. Trace the clone and fetch path used by RepoBuilder, then verify that repeated clones release memory and add or run a focused regression test if the repository provides one.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, rust
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.