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!
What is a reference to an object? It is the address of variable only -- not the method of an object. It is a shallow pointer that contains address of an object. It is the physical address of an object. It is the address where the variables and methods of an object are stored.
As you work with objects, it's important to understand references. A reference is an address that indicates where an object's variables and methods are stored. You aren't actually using objects when you assign an object to a variable or pass an object to a method as an argument.
A reference is an address that indicates where an object's variables and methods are stored. You aren't actually using objects when you assign an object to a variable or pass an object to a method as an argument.
This post is a response to those debates. To be clear, Go does not have reference variables, so Go does not have pass-by-reference function call semantics. What is a reference variable? In languages like C++ you can declare an alias, or an alternate name to an existing variable.
I can suggest two tools.
Use Go Guru, to see who pointsto or referrers to a pointer. It is integrated with the vim-go plugin I use, I did a post on that here.
Valgrind is a tool for C/C++ but found an article about using it with Go.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With