-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Potential Memory Leak in mg_timer_free
Function
#2768
Comments
In our tutorials and examples https://mongoose.ws/documentation/#tutorials-and-examples we don't free timers. |
My use case involves managing 10 different connections, each with its own timer. When a disconnection occurs, I need to free the associated timers. This is important because maintaining timers for inactive connections can lead to unnecessary resource consumption and potential memory leaks. By freeing the timers upon disconnection, I ensure efficient resource management and system stability. Although typical usage scenarios may involve a small number of timers that are restarted as needed, my specific requirement necessitates the creation and disposal of multiple timers dynamically, making it crucial to free them when they are no longer needed. |
Well, I´d rather not go alloc'ing and freeing in the first place but as Mongoose uses dynamic memory allocation there's nothing we can do about it. |
Thank you for your interest and support! |
BTW, there are other ways to implement per connection timers. |
I am going to check it out, thank you for your suggestion, |
Description
I have encountered a potential memory leak issue in the Mongoose library related to the
mg_timer_free
function. This function is intended to free timers, but it appears to leave behind some memory blocks, leading to a memory leak.Function Definition
Issue Details
In my application, I observe that memory usage increases over time when timers are frequently created and freed using the mg_timer_free function. The current implementation removes the specified timer "t" from the linked list but does not explicitly free the memory allocated for the removed timer, which seems to result in a memory leak.
Question
I appreciate any insights or recommendations you can provide regarding this issue. Thank you for your assistance!
Best Regards,
Kerem
The text was updated successfully, but these errors were encountered: