I am currently trying to debug a nasty memory leak in our Go code.
What I know:
pprof
with -base
flag)runtime.NumGoroutine()
)object = nil
, memory will be garbage collected (good! but now I have data races with other go-routines that are using this object)What I don't know:
Thank you for your time and any advice!
Your code is 404 not found.
When you put object = nil. this did not be cleared immediately however when some goroutine still holds it , the object will keep still even if gc runs.
You ask who hold the reference, goroutine who uses this val without put it to nil or the goroutine uses it in a loop will both keep the reference.
The gc() will never marked a referred reference to black, then it will never be clear