mirror of
https://github.com/rclone/rclone
synced 2024-11-04 00:27:50 +01:00
accounting: fix memory leak noticeable for transfers of large numbers of objects
Before this fix we weren't removing transfers from the transfer stats. For transfers with 1000s of objects this uses a noticeable amount of memory. See: https://forum.rclone.org/t/rclone-memory-consumption-increasing-linearly/12244
This commit is contained in:
parent
90a23ae01b
commit
e337cae0c5
@ -532,3 +532,16 @@ func (s *StatsInfo) AddTransfer(transfer *Transfer) {
|
||||
s.startedTransfers = append(s.startedTransfers, transfer)
|
||||
s.mu.Unlock()
|
||||
}
|
||||
|
||||
// RemoveTransfer removes a reference to the started transfer.
|
||||
func (s *StatsInfo) RemoveTransfer(transfer *Transfer) {
|
||||
s.mu.Lock()
|
||||
for i, tr := range s.startedTransfers {
|
||||
if tr == transfer {
|
||||
// remove the found entry
|
||||
s.startedTransfers = append(s.startedTransfers[:i], s.startedTransfers[i+1:]...)
|
||||
break
|
||||
}
|
||||
}
|
||||
s.mu.Unlock()
|
||||
}
|
||||
|
@ -113,6 +113,7 @@ func (tr *Transfer) Done(err error) {
|
||||
} else {
|
||||
tr.stats.DoneTransferring(tr.remote, err == nil)
|
||||
}
|
||||
tr.stats.RemoveTransfer(tr)
|
||||
}
|
||||
|
||||
// Reset allows to switch the Account to another transfer method.
|
||||
|
Loading…
Reference in New Issue
Block a user