Skip to content

Removes two entry points for memory leaks#182

Merged
NeedleInAJayStack merged 2 commits into
GraphQLSwift:mainfrom
jwsinner:fix/memory-leak
Jun 25, 2026
Merged

Removes two entry points for memory leaks#182
NeedleInAJayStack merged 2 commits into
GraphQLSwift:mainfrom
jwsinner:fix/memory-leak

Conversation

@jwsinner

Copy link
Copy Markdown

Updates Token.prev to be a weak var to prevent memory leaks caused by reference cycles in the AST.

Updates ValidationContext to use an override of report(error: GraphQLError) rather than capturing itself strongly in the onError closure.

Adds GraphQLMemoryRetentionTests.swift with two regression tests to validate these changes remove these leaks.

Makes Token.prev a weak var preventing retention if a cyclec occur in the graph. ValidationContext no longer captures itself strongly in assigning onError; uses an override of report instead. Regression tests were added to validate the fixes
@jwsinner jwsinner changed the title fix: removes two entry points for memory leaks Removes two entry points for memory leaks Jun 24, 2026
@NeedleInAJayStack NeedleInAJayStack self-requested a review June 24, 2026 15:53

@NeedleInAJayStack NeedleInAJayStack left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! Great find, and thanks for contributing these fixes!

Comment thread Sources/GraphQL/Validation/ValidationContext.swift Outdated
@NeedleInAJayStack NeedleInAJayStack merged commit d3366a2 into GraphQLSwift:main Jun 25, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants