Skip to content

Fix/return dict to Event pool#749

Merged
rs merged 3 commits intors:masterfrom
IDisposable:fix/return-dict-to-pool
Jan 12, 2026
Merged

Fix/return dict to Event pool#749
rs merged 3 commits intors:masterfrom
IDisposable:fix/return-dict-to-pool

Conversation

@IDisposable
Copy link
Copy Markdown
Contributor

Ensure dict is returned to Event pool in Array.Dict()
Ensure dict is returned to Event pool in Event.Dict(). Previously it was not returning it to the pool if the Event was nil
Update Concurrency safety documentation to note that Array.Dict() also resets the dict and returns to Event pool.

Fixes #681

Copilot AI review requested due to automatic review settings January 12, 2026 21:35
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes memory leaks in dictionary handling by ensuring that dictionary Event objects are always returned to the event pool after use, even when the parent Event is nil (e.g., when logging is disabled).

Changes:

  • Fixed Event.Dict() to always return dict to pool, even when Event is nil
  • Fixed Array.Dict() to return dict to pool after use
  • Updated documentation to clarify that Array.Dict() also clears and returns dict to pool

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
event.go Refactored Event.Dict() to unconditionally call putEvent(dict), fixing memory leak when Event is nil
array.go Added missing putEvent(dict) call in Array.Dict() to return dict to pool
README.md Updated concurrency safety documentation to include Array.Dict() in the list of methods that return dict to pool

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@rs rs merged commit a0d61dc into rs:master Jan 12, 2026
10 of 11 checks passed
@IDisposable IDisposable deleted the fix/return-dict-to-pool branch January 12, 2026 22:56
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.

Question: Using Dict Inside an Array would not put back the byte buffer back into pool, is this the expectation?

3 participants