Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cloudwego/goref
Go heap object reference analysis tool
https://github.com/cloudwego/goref
Last synced: 3 months ago
JSON representation
Go heap object reference analysis tool
- Host: GitHub
- URL: https://github.com/cloudwego/goref
- Owner: cloudwego
- License: apache-2.0
- Created: 2024-07-10T02:53:01.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-08-08T11:03:25.000Z (3 months ago)
- Last Synced: 2024-08-08T13:12:11.804Z (3 months ago)
- Language: Go
- Size: 58.6 KB
- Stars: 399
- Watchers: 8
- Forks: 14
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE-APACHE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Goref
[![WebSite](https://img.shields.io/website?up_message=cloudwego&url=https%3A%2F%2Fwww.cloudwego.io%2F)](https://www.cloudwego.io/)
[![License](https://img.shields.io/github/license/cloudwego/goref)](https://github.com/cloudwego/goref/blob/main/LICENSE-APACHE)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 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
```The opened HTML page displays the reference distribution of the heap memory. You can choose to view the "inuse space" or "inuse objects".
> DWARF parsing of closure type was not supported before Go 1.23, so sub objects of `wpool.task` cannot be displayed.
View flame graph of inuse objects:
It also supports analyzing core files, e.g.
```
$ grf core ${execfile} ${corefile}
successfully output to `grf.out`
```## Go Version Constraints
- Executable file: go1.17 ~ go1.22.
- Compile goref tool: >= go1.21.## Docs
[Principle](docs/principle.md) | [实现原理](docs/principle_cn.md)
## Credit
Thanks to [Delve](https://github.com/go-delve/delve) for providing powerful golang debugger.