Skip to content

Commit

Permalink
Fix plugins memory leak
Browse files Browse the repository at this point in the history
Long story short, when changing NewAgent method to functional params, was done using pointers in the plugins struct.

Switching to not use pointers at all allows for the GC to pass.
  • Loading branch information
Victor Castell committed Oct 1, 2019
1 parent d0e9943 commit e26811a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func agentRun(args ...string) error {
if err := p.DiscoverPlugins(); err != nil {
log.Fatal(err)
}
plugins := &dkron.Plugins{
plugins := dkron.Plugins{
Processors: p.Processors,
Executors: p.Executors,
}
Expand Down
8 changes: 3 additions & 5 deletions dkron/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ import (
)

// WithPlugins option to set plugins to the agent
func WithPlugins(plugins *Plugins) AgentOption {
func WithPlugins(plugins Plugins) AgentOption {
return func(agent *Agent) {
if plugins != nil {
agent.ProcessorPlugins = plugins.Processors
agent.ExecutorPlugins = plugins.Executors
}
agent.ProcessorPlugins = plugins.Processors
agent.ExecutorPlugins = plugins.Executors
}
}

Expand Down

0 comments on commit e26811a

Please sign in to comment.