Skip to content

Conversation

@e-gineer
Copy link
Contributor

Summary

  • Fix memory leak in explain.go where C.CString() allocations were never freed
  • Store CString results in variables and use defer C.free() after use

Details

The Property() function was passing C.CString() results directly to ExplainPropertyText without storing them, making them impossible to free. C.CString() allocates on the C heap and must be explicitly freed.

Impact

  • Risk: Low - EXPLAIN is not a hot path
  • Frequency: Only during EXPLAIN queries (development/debugging)
  • Memory: ~50-100 bytes leaked per EXPLAIN property

Test plan

  • Verified EXPLAIN queries still work correctly
  • Memory testing shows no regression

Fixes #617

🤖 Generated with Claude Code

C.CString() allocates on the C heap and must be explicitly freed.
The Property() function was passing CString results directly to
ExplainPropertyText without storing them, making them impossible to free.

Fix: Store CString results in variables and defer C.free() calls.
Using defer is appropriate here since EXPLAIN is not a hot path.

Fixes #617

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

Memory leak: CString not freed in explain.go Property()

2 participants