proposal: scan and record memory partially

Open
#71 0 comments 0 reactions 0 assignees View on GitHub

@Lslightly is already working on this.

Since Jun 18, 2026.

  • #75 by @Lslightly — open

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
38/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
go
Domain
tooling

Research direction

Start by reviewing the markStub branch and its demo at test/testdata/stubaddr/main.go. Determine how the proposed stub pointer should be added to selected struct types and how goref should identify reachable objects from the supplied address. Done means the feature supports partial scanning of isolated memory regions, with coverage for the demonstrated use case and its memory-cost tradeoff considered.

Written by the indexing model from the issue text.

Description

Is your feature request related to a problem? Please describe.

When the memory footprint is large, we may only consider some part of objects, which can reduce the size of generated profile.
Although pprof provides show_from and focus options to hide other parts of objects, there may be cases we need to consider two isolated parts of memory at the same time.

Describe the solution you'd like

Intrusively add a stub pointer field to the struct types of interest within the program under test. Then goref can trace objects reachable from struct objects which holds the stub address provided by goref.

Describe alternatives you've considered

Write goref profile parser and consider interested objects only. But it seems not convenient as this approach.
But stub field in the proposal causes more memory consumption for objects which contain the field.

Additional context

I've implemented the idea in markStub branch. It supports adding a stub pointer in objects of struct type. Then goref will only trace objects reachable from those objects that contain the stub address.

test/testdata/stubaddr/main.go is a demo program to show how markStub can be used to trace certain objects.

Dominant language
Go
Stars
1k
Forks
49
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from cloudwego/goref

All issues in cloudwego/goref

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.