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
This commit is contained in:
Nick Craig-Wood 2019-10-15 16:39:06 +01:00
parent e337cae0c5
commit 543100070a

View File

@ -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