Goref is a Go heap object reference analysis tool that helps developers understand memory allocation patterns and identify memory leaks by visualizing which code locations hold references to heap objects.
The tool works by attaching to a running Go process using its PID and leveraging the delve debugger to analyze heap memory. It generates a profile showing the space and object count distribution across the call stack, displaying which code paths are responsible for creating and retaining heap objects. The output can be viewed through the pprof tool in an interactive HTML interface where developers can toggle between viewing inuse space or inuse object counts. This approach makes it possible to see the actual reference distribution of heap objects reachable by the garbage collector, allowing developers to pinpoint code locations that are holding references and causing memory to persist.
Goref suits teams working on long-running Go services where memory optimization matters, particularly when investigating suspected memory leaks or when reducing garbage collector overhead is a priority. It works with Go versions from 1.19 through 1.26 and can analyze both live processes and core files. The tool is most valuable when you need to move beyond generic memory profiling to understand the specific reference chains keeping objects alive in memory.
The project shows consistent maintenance with regular updates addressing issues and improving functionality. Development activity demonstrates responsiveness to user feedback and bug reports. The tool receives ongoing refinement to expand compatibility across Go versions and enhance the analysis capabilities available to users.