]> Cypherpunks repositories - gostls13.git/commitdiff
container/heap: remove confusing claim of memory leak
authorcodesoap <codesoap@mailbox.org>
Wed, 31 Jan 2024 18:31:56 +0000 (18:31 +0000)
committerRobert Griesemer <gri@google.com>
Wed, 31 Jan 2024 20:27:36 +0000 (20:27 +0000)
The term "memory leak" was misused here, as the memory is still referenced
by the slice.

Fixes #65403

Change-Id: Id102419d4c798fb2a4ec8be86be9ec9b5cdd98e6
GitHub-Last-Rev: 3febcd0ba4ab5897bef8f2d7ded594ef09932771
GitHub-Pull-Request: golang/go#65404
Reviewed-on: https://go-review.googlesource.com/c/go/+/559775
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/container/heap/example_pq_test.go

index 4511b6c33e0ff70f64eaf00261816ee536070cb2..26331f312d1933b5f71bc5a8bf2f9d9a80ded2b0 100644 (file)
@@ -45,7 +45,7 @@ func (pq *PriorityQueue) Pop() any {
        old := *pq
        n := len(old)
        item := old[n-1]
-       old[n-1] = nil  // avoid memory leak
+       old[n-1] = nil  // don't stop the GC from reclaiming the item eventually
        item.index = -1 // for safety
        *pq = old[0 : n-1]
        return item