-
Notifications
You must be signed in to change notification settings - Fork 81
Description
Version
7.3.0
Operating System
Linux/Unix
Bug description
After upgrading jgit from 7.0.0.0.202409031743-r to 7.3.0.202506031305-r, the service starts consuming more memory than before.
Working with jgit version 7.0.0.0.202409031743-r the service uses ~2.35 GB (75% of existing memory) with a container memory limit of 3.15 GB, see first image.
After upgrading jgit to version 7.3.0.202506031305-r the service started consuming all the memory available in the container. Then, after adding an additional 1 GB of memory for the container(container memory limit = 4.19 GB), the service started consuming more memory than before update (almost 1.2 GB more at peak), see second image. The load from users on the service has not increased.
Since I had previously had memory issues with jgit, I decided to just downgrade jgit to the previous version 7.0.0.0.0.202409031743-r without any changes to the settings (just removed the extra 1 gigabyte of memory for the container that was added earlier after the service failed). After that the memory consumption was back to normal, see second image.
No change in java memory consumption, XMX has the same numbers when using both versions of jgit.
A year ago I found that jgit uses a lot of off-heap memory when cloning a project, almost 1.5 times the size of the repository. To solve this problem, I use ReentrantLock so that multiple repositories are not cloned at one time, but only 1 project can be cloned at a time.
Kotlin code:
private val cloningLock = ReentrantLock()
fun internalWithClonedProject(cloneUrl: String, startBranch: String? = null, spec: (git: Git) -> Unit) {
try {
cloningLock.lock()
log.trace { "Lock taken for cloning $cloneUrl" }
GitWorkingCopy().use { workingCopy ->
Git.cloneRepository()
.setURI(cloneUrl)
.setBranch(startBranch)
.setDirectory(workingCopy.dir)
.call()
.use { git -> // function use in kotlin closes resources, it will invoke close() method on Git
spec(git)
}
}
} finally {
cloningLock.unlock()
log.trace { "Lock is released for $cloneUrl" }
}
private class GitWorkingCopy : AutoCloseable {
val dir: File = Files.createTempDirectory("temp-").toFile()
override fun close() {
dir.deleteRecursively()
}- What could have caused a significant increase in memory?
- Maybe there are some settings to limit the off-heap memory consumption?
Actual behavior
Significant increase in memory
Expected behavior
Relevant log output
Other information
