From 1e9ad3e22a57323ec3b8981d5c6128804904f21a Mon Sep 17 00:00:00 2001 From: Jeremy Stribling Date: Mon, 30 Oct 2017 15:31:23 -0700 Subject: packfile: delete index maps from memory when no longer needed This helps keep memory usage stable while calculating deltas. --- plumbing/format/packfile/delta_selector.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'plumbing') 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 -- cgit