Skip to content

Commit

Permalink
fix GC issue: release []rune when reusing the runner. which leads to …
Browse files Browse the repository at this point in the history
…'runtext' and 'runmatch.text' inability to be garbage collected until next use. (dlclark#81)
  • Loading branch information
chinaykc authored Jul 11, 2024
1 parent 5d49e36 commit 30daa31
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -1604,6 +1604,10 @@ func (re *Regexp) getRunner() *runner {
// run using re. (The cache empties when re gets garbage collected.)
func (re *Regexp) putRunner(r *runner) {
re.muRun.Lock()
r.runtext = nil
if r.runmatch != nil {
r.runmatch.text = nil
}
re.runner = append(re.runner, r)
re.muRun.Unlock()
}

0 comments on commit 30daa31

Please sign in to comment.