From 543100070a2caf873a61b8dfe6d74659ed2c84a6 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Tue, 15 Oct 2019 16:39:06 +0100 Subject: [PATCH] sync: free objects after they come out of the transfer pipe This reduces memory when the transfer pipe shrinks See: https://forum.rclone.org/t/rclone-memory-consumption-increasing-linearly/12244 --- fs/sync/pipe.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/sync/pipe.go b/fs/sync/pipe.go index 0caf3f77a..1af0e684a 100644 --- a/fs/sync/pipe.go +++ b/fs/sync/pipe.go @@ -68,7 +68,10 @@ func (p *pipe) Get(ctx context.Context) (pair fs.ObjectPair, ok bool) { } } p.mu.Lock() - pair, p.queue = p.queue[0], p.queue[1:] + pair = p.queue[0] + p.queue[0].Src = nil + p.queue[0].Dst = nil + p.queue = p.queue[1:] size := pair.Src.Size() if size > 0 { p.totalSize -= size