Skip to content

Commit

Permalink
[Issue 5589][pulsar-function-go] Fix a memory leak of pulsar-function…
Browse files Browse the repository at this point in the history
…-go library (apache#5592)

StrEntry variable should be cleared after finish addLogTopicHandler()
function regardless the log messages are appended to logger or not. If
it is not cleared, it causes memory leak because StrEntry has grown
indefinitely. Moreover, if the function set --log-topic, then the topic
could get accumulated huge messages that cause ProducerQueueIsFull
error.
  • Loading branch information
Sunkwan-Kwon authored and sijie committed Dec 3, 2019
1 parent 9137065 commit 387e290
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pulsar-function-go/pf/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,11 @@ func (gi *goInstance) setupLogHandler() error {
}

func (gi *goInstance) addLogTopicHandler() {
// Clear StrEntry regardless gi.context.logAppender is set or not
defer func() {
log.StrEntry = nil
}()

if gi.context.logAppender == nil {
log.Error("the logAppender is nil, if you want to use it, please specify `--log-topic` at startup.")
return
Expand Down

0 comments on commit 387e290

Please sign in to comment.