mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-29 00:16:25 +00:00
See https://github.com/grpc/grpc-go/issues/4758 for a real world example of this leaking 2gb+ of data. Basically, when we do `q.queue[1:]` we are just repositioning the slice. The underlying array is still active, which contains the object formerly known as `q.queue[0]`. Because its referencing this object, it will not be GCed. The only thing that will trigger it to free is eventually when we add enough to the queue that we allocate a whole new array. Instead, we should explicitly clear out the old space when we remove it from the queue. This ensures the object can be GCed, assuming the users' application doesn't reference it anymore. Kubernetes-commit: 2a34801168dc1c70ba25b1d4200b534bf515cbc2