Skip to content

Commit

Permalink
Autodiscover memleak (#41748) (#42436)
Browse files Browse the repository at this point in the history
* Create a clone to release source struct from mem

* Cleanup meta on stop events

* Add changelog entry

---------

Co-authored-by: Mauri de Souza Meneguzzo <[email protected]>
(cherry picked from commit bb5032e)

Co-authored-by: Rafael da Fonseca <[email protected]>
Co-authored-by: Mauri de Souza Meneguzzo <[email protected]>
  • Loading branch information
3 people authored Jan 27, 2025
1 parent 00afa35 commit 00afe60
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
- Fix a bug where log files are rotated on startup when interval is configured and rotateonstartup is disabled {issue}41894[41894] {pull}41895[41895]
- Fix setting unique registry for non beat receivers {issue}42288[42288] {pull}42292[42292]
- The Kafka output now drops events when there is an authorisation error {issue}42343[42343] {pull}42401[42401]
- Fix autodiscovery memory leak related to metadata of start events {pull}41748[41748]

*Auditbeat*

Expand Down
7 changes: 6 additions & 1 deletion libbeat/autodiscover/autodiscover.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,11 @@ func (a *Autodiscover) handleStop(event bus.Event) bool {
updated = true
}

// Cleanup meta references for this eventID
for configHash := range a.configs[eventID] {
a.meta.Remove(configHash)
}

delete(a.configs, eventID)

return updated
Expand All @@ -300,7 +305,7 @@ func (a *Autodiscover) getMeta(event bus.Event) mapstr.M {
a.logger.Errorf("Got a wrong meta field for event %v", event)
return nil
}
return meta
return meta.Clone()
}

// getID returns the event "id" field string if present
Expand Down

0 comments on commit 00afe60

Please sign in to comment.