From 7446b0c82bf4eb3e8cafbce76058463c2e95241e Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 20 Nov 2017 17:52:09 -0800 Subject: [PATCH] nil out references to finished dials We need a better solution (this is a memory hotspot when mass dialing) but that will take some thought and effort. This is a simple fix that should reduce memory usage a bit. --- limiter.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/limiter.go b/limiter.go index f2513d8..f6cf6dd 100644 --- a/limiter.go +++ b/limiter.go @@ -71,6 +71,7 @@ func (dl *dialLimiter) finishedDial(dj *dialJob) { if len(dl.waitingOnFd) > 0 { next := dl.waitingOnFd[0] + dl.waitingOnFd[0] = nil // clear out memory dl.waitingOnFd = dl.waitingOnFd[1:] if len(dl.waitingOnFd) == 0 { dl.waitingOnFd = nil // clear out memory @@ -94,6 +95,7 @@ func (dl *dialLimiter) finishedDial(dj *dialJob) { if len(waitlist) == 1 { delete(dl.waitingOnPeerLimit, dj.peer) } else { + waitlist[0] = nil // clear out memory dl.waitingOnPeerLimit[dj.peer] = waitlist[1:] } dl.activePerPeer[dj.peer]++ // just kidding, we still want this token -- GitLab