I'm running a script that check a repo for Diff.indexToWorkdir every interval, like so:
// runs in interval every 1s
.then(() => {
return git.Repository.open('../my_repo_path');
})
.then( (repo) => {
return git.Diff.indexToWorkdir(repo);
})
.then((repoDiff) => {
return repoDiff.toBuf(git.Diff.FORMAT.PATCH);
})
This generates a memory leak.
I know the repository needs to be freed using repo.free(): (or repo.cleanup())
https://www.nodegit.org/api/repository/#free
According to the docs:
https://libgit2.org/libgit2/#HEAD/group/repository/git_repository_free
Note that after a repository is free'd, all the objects it has spawned will still exist until they are manually closed by the user with git_object_free, but accessing any of the attributes of an object without a backing repository will result in undefined behavior
Which means I also need to free up the Diff object;
Apparently there's a way to free a diff using git_diff_free
https://libgit2.org/libgit2/#HEAD/group/diff/git_diff_free
But from what I understand nodegit doesn't expose this function, see:
|
"git_diff_free": { |
|
"ignore": true |
|
}, |
EDIT
It seems like I also need to free up the Buf I'm creating using repoDiff.toBuf(git.Diff.FORMAT.PATCH);
https://www.nodegit.org/api/buf/#free
https://libgit2.org/libgit2/#HEAD/group/buf/git_buf_free
But I didn't find a way to do this since repoDiff.toBuf return a Promise which returns a string.
It seems the Buf is only available in the C++ implementation. (see NAN_METHOD(GitDiff::ToBuf) )
Is there another way to do this?
Thanks
BTW, I'm guessing this also relates to: #766
I'm running a script that check a repo for
Diff.indexToWorkdirevery interval, like so:This generates a memory leak.
I know the repository needs to be freed using
repo.free(): (orrepo.cleanup())https://www.nodegit.org/api/repository/#free
According to the docs:
https://libgit2.org/libgit2/#HEAD/group/repository/git_repository_free
Which means I also need to free up the Diff object;
Apparently there's a way to free a diff using
git_diff_freehttps://libgit2.org/libgit2/#HEAD/group/diff/git_diff_free
But from what I understand nodegit doesn't expose this function, see:
nodegit/generate/input/descriptor.json
Lines 933 to 935 in c944ec6
EDIT
It seems like I also need to free up the
BufI'm creating usingrepoDiff.toBuf(git.Diff.FORMAT.PATCH);https://www.nodegit.org/api/buf/#free
https://libgit2.org/libgit2/#HEAD/group/buf/git_buf_free
But I didn't find a way to do this since
repoDiff.toBufreturn a Promise which returns a string.It seems the
Bufis only available in the C++ implementation. (see NAN_METHOD(GitDiff::ToBuf) )Is there another way to do this?
Thanks
BTW, I'm guessing this also relates to: #766