[fix][plugin][pulsar] Clean message context after message is recycled to prevent memory leak.#405
Conversation
If you mean @tisonkun @codelipenghui Could any of you confirm this? |
in my opinion, I just feeling that release the tracing context as soon as the message recycled will be helpful to saving the heap memory. |
|
there is also a problem, I'm not sure that if fix it is better: |
About how to get the duration accurate, I think you are better than me. Pulsar plugin mostly was added in 2019, and there was no |
|
There is one point I need to explain: |
|
This field is initialized as null. Basically, this should be fine. |
|
@tjiuming Oops, you seem missed the changes.md update. Please submit another PR to add one. |
OK |
Currently, we set
new MessageEnhanceRequiredInfo()intoMessageImplto store the tracing context.But Pulsar has a Recycle mechanism, see: https://github.com/apache/pulsar/blob/master/pulsar-client/src/main/java/org/apache/pulsar/client/impl/MessageImpl.java#L126
The
MessageImplwill not GC by JVM, so thenew MessageEnhanceRequiredInfo()settled intoMessageImplwon't be GC too, it will lead to memory leak.The PR will clean the
new MessageEnhanceRequiredInfo()settled intoMessageImplto prevent memory leak.CHANGESlog.