-
Notifications
You must be signed in to change notification settings - Fork 534
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
Use "time.After" may cause a memory leak #518
Comments
Please point out where in this library the memory leak is? The comment you pasted does not say that There is a potential in that a very high volume publisher may see extra memory usage (due to the call to |
Yes, we now use mqtt to communicate in the intranet. The speed of sending and receiving is very fast, about 10-20ms to send data. In the Publish function, time. After will be called frequently, so the memory will continue to grow for a long time to stabilize.I think it's more reasonable to use time.NewTicker here.This can solve unnecessary memory occupation. |
Why are you preferring The change should be fairly simple:
|
Yes, just like you said. For devices with very small memory (for example, my embedded device has only 128M memory), I think this is more reasonable. |
Whether time. Newticker or time. Newtimer, resources will be released after calling Stop. It's more reasonable to use time. Newtimer here. Thank you for your correction. |
FYI this is the only way to avoid memory leak:
|
我的也是这个,这个问题造成了内存泄漏,这个文件在哪,怎么修改 |
The text was updated successfully, but these errors were encountered: