提交 387e2907 编写于 作者: S Sunkwan Kwon 提交者: Sijie Guo

[Issue 5589][pulsar-function-go] Fix a memory leak of pulsar-function-go library (#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.
上级 9137065f
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册