MCPcopy Index your code
hub / github.com/cloudwego/goref

github.com/cloudwego/goref @v0.0.11

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.0.11 ↗ · + Follow
281 symbols 795 edges 29 files 97 documented · 35% 1 cross-repo links updated 3mo agov0.0.11 · 2026-03-05★ 1,0134 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Goref

English | 中文

WebSite License

Goref is a Go heap object reference analysis tool based on delve.

It can display the space and object count distribution of Go memory references, which is helpful for efficiently locating memory leak issues or viewing persistent heap objects to optimize the garbage collector (GC) overhead.

Installation

$ go install github.com/cloudwego/goref/cmd/grf@latest

Usage

Attach to a running process with its PID, and then use go pprof tool to open the output file.

$ grf attach ${PID}
successfully output to `grf.out`
$ go tool pprof -http=:5079 ./grf.out

Please be aware that grf attach will suspend the program until the command exits.

The opened HTML page displays the reference distribution of the heap memory. You can choose to view the "inuse space" or "inuse objects".

For example, the heap profile sampled from a testing program is shown below, which reflects the call stack distribution of object creation.

img_v3_02gq_63631612-6f2d-40ce-8f98-a4e52682ef7g

By using the goref tool, you can see the memory reference distribution of heap objects reachable by GC, thereby quickly pinpointing the actual code locations holding references.

img_v3_02gq_53dc2cff-203a-4c06-9678-aae49da4754g

img_v3_02gq_54551396-a4ae-42b8-996f-1b1699d381dg

It also supports analyzing core files, e.g.

$ grf core ${execfile} ${corefile}
successfully output to `grf.out`

Go Version Constraints

  • Executable file: go1.19 ~ go1.26
  • Compile goref tool: >= go1.21

Docs

How it Works | Advanced Usage

Credit

Thanks to Delve for providing powerful golang debugger.

Extension points exported contracts — how you extend this code

ProfileNodeInterface (Interface)
ProfileNodeInterface defines the interface for accessing profile node data [1 implementers]
test/framework.go
ReqE (Interface)
(no doc) [3 implementers]
test/testdata/alltypes/main.go

Core symbols most depended-on inside this repo

ExactValue
called by 58
test/framework.go
Add
called by 56
pkg/proc/address.go
Field
called by 38
pkg/proc/region.go
String
called by 31
test/testdata/alltypes/main.go
genericString
called by 31
test/testdata/alltypes/main.go
readUintRaw
called by 27
pkg/proc/variables.go
HasField
called by 16
pkg/proc/region.go
toField
called by 15
pkg/proc/variables.go

Shape

Method 155
Function 72
Struct 44
TypeAlias 7
Interface 3

Languages

Go100%

Modules by API surface

pkg/proc/heap.go46 symbols
test/framework.go32 symbols
pkg/proc/protobuf.go30 symbols
pkg/proc/mapiter.go27 symbols
pkg/proc/region.go25 symbols
pkg/proc/variables.go24 symbols
test/testdata/alltypes/main.go18 symbols
pkg/proc/reference.go13 symbols
pkg/proc/unsafe.go10 symbols
pkg/proc/runtime.go8 symbols
test/testdata/rangeoverfunc/main.go6 symbols
test/testdata/mockleak/creator/creator.go5 symbols

Used by 1 indexed graphs manifest dependencies, hub-wide

For agents

$ claude mcp add goref \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact