Skip to content

fix(OOM): There is a memory leak problem in the queue #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rayne-qvq
Copy link

I discovered a memory leak issue during actual use. Through pprof's investigation, it was found that it was caused by the log service.

After investigation, it was found that there is a risk of memory leakage in the queue's memory

Goroutine leakage in the Append method: Whenever a new log message enters the queue, the Append method starts a new goroutine to put the message into the channel. When the queue is full, this goroutine will be blocked and will never be released. If the log generation speed is higher than the processing speed, it will lead to a large number of goroutine leaks, thereby depleting memory.

Modify the Append method: Remove unnecessary goroutines and send messages to the channel in a non-blocking manner. If the queue is full, the message will be directly discarded and a log will be printed, while an error will be returned. This can fundamentally solve the problem of Goroutine leakage.

I discovered a memory leak issue during actual use. Through pprof's investigation, it was found that it was caused by the log service.

After investigation, it was found that there is a risk of memory leakage in the queue's memory



Goroutine leakage in the Append method: Whenever a new log message enters the queue, the Append method starts a new goroutine to put the message into the channel. When the queue is full, this goroutine will be blocked and will never be released. If the log generation speed is higher than the processing speed, it will lead to a large number of goroutine leaks, thereby depleting memory.



Modify the Append method: Remove unnecessary goroutines and send messages to the channel in a non-blocking manner. If the queue is full, the message will be directly discarded and a log will be printed, while an error will be returned. This can fundamentally solve the problem of Goroutine leakage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant