Skip to content

Reduce TestEnv object leaks#10771

Open
stephanos wants to merge 46 commits into
mainfrom
stephanos/object-leak-cleanup
Open

Reduce TestEnv object leaks#10771
stephanos wants to merge 46 commits into
mainfrom
stephanos/object-leak-cleanup

Conversation

@stephanos

@stephanos stephanos commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

What changed?

Reduce TestEnv object leaks by explicitly nil-ing fields in t.Cleanup.

Why?

Reduce object leaks after cluster teardown.

dedicatedGuard: dedicatedGuard,
}
dedicatedGuardRef := &dedicatedGuard
t.Cleanup(func() {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is interesting; the t.Cleanup keeps these references alive and prevents GC until the test completes. Only then is the Cleanup closure GC itself. So this means in longer suites with several tests, the clusters are all accumulating until the very end. By nil-ing them, we force that to happen sooner.

@stephanos stephanos force-pushed the stephanos/object-leak-cleanup branch 3 times, most recently from dc4d2cf to ad085c8 Compare June 18, 2026 22:10
Base automatically changed from stephanos/cluster_gc_test to main June 19, 2026 18:22
@stephanos stephanos force-pushed the stephanos/object-leak-cleanup branch from 457eb7d to 5d5c197 Compare June 19, 2026 18:33
@stephanos stephanos marked this pull request as ready for review June 19, 2026 18:33
@stephanos stephanos requested review from a team as code owners June 19, 2026 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant