eclipse-jgit / jgit

JGit, the Java implementation of git
https://www.eclipse.org/jgit/
Other
92 stars 31 forks source link

After calling the revwalk.parseCommit method, the file handle is not released, which may cause a memory leak. #40

Closed sixther-dc closed 4 months ago

sixther-dc commented 4 months ago

Version

6.8.0

Operating System

Linux/Unix

Bug description

I use the public RevCommit parseCommit(final AnyObjectId id) method to get the commit and its content。Over time, my application memory will gradually increase until oom。 After I dumped the memory, I found that the top1 object is PackIndexV2。 image I noticed that there is an open operation in the implementation of the parseCommit method, and I suspect that it opened the file without releasing it, causing a memory leak. So, I logged into the server and used the lsof command to view the pack file opened by the java process.

image

Moreover, with the end of the stress testing process, the number of open files has not decreased.

Actual behavior

After the parseCommit method call ends, the pack file descriptor is not released,

Expected behavior

After the parseCommit method is called, the pack file descriptor is released normally to save memory.

Relevant log output

No response

Other information

No response

sixther-dc commented 4 months ago

I call the repo.close method to avoid memory leak, the opened file handle have been released.