aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/format/packfile
diff options
context:
space:
mode:
authorJeremy Stribling <strib@alum.mit.edu>2017-10-30 15:31:23 -0700
committerJeremy Stribling <strib@alum.mit.edu>2017-10-30 16:04:59 -0700
commit1e9ad3e22a57323ec3b8981d5c6128804904f21a (patch)
treede81dcaa714eecce25654927415cf4c65ce16821 /plumbing/format/packfile
parent50732e34e5304e3a32e87a8937faad4d7b845e50 (diff)
downloadgo-git-1e9ad3e22a57323ec3b8981d5c6128804904f21a.tar.gz
packfile: delete index maps from memory when no longer needed
This helps keep memory usage stable while calculating deltas.
Diffstat (limited to 'plumbing/format/packfile')
-rw-r--r--plumbing/format/packfile/delta_selector.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/plumbing/format/packfile/delta_selector.go b/plumbing/format/packfile/delta_selector.go
index 77573ac..51adcdf 100644
--- a/plumbing/format/packfile/delta_selector.go
+++ b/plumbing/format/packfile/delta_selector.go
@@ -227,6 +227,12 @@ func (dw *deltaSelector) walk(
) error {
indexMap := make(map[plumbing.Hash]*deltaIndex)
for i := 0; i < len(objectsToPack); i++ {
+ // Clean up the index map for anything outside our pack
+ // window, to save memory.
+ if i > int(packWindow) {
+ delete(indexMap, objectsToPack[i-int(packWindow)].Hash())
+ }
+
target := objectsToPack[i]
// If we already have a delta, we don't try to find a new one for this