-
Notifications
You must be signed in to change notification settings - Fork 29
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
fix(windows): memory leaks #53
Conversation
The windows function works on a pointer of known size, so no allocation is required. This also fixes the leak. Also use the winapi type (which actually is u32).
Ok, this should be the more idiomatic fix. Sorry for the noise. |
about allocation retry count, in my use case it's possible that new interfaces appears in 5-10 per second. So one retry might not be enough tbh. |
Mmh, the documentation https://docs.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-getadaptersaddresses#return-value is slightly vague. What does "multiple times" mean? Maybe the counter should actually be kept. In my environment, the initial call fails (probably due the various VPN virtual adapters on that machine), the second one works. |
Hi guys! Currently I dont have a Windows Environment I could test against. Changes seems okay so far, have you had any issues with this version? |
It would be nice te have any memory usage audition tool integrated in CI! Im curious on the fact that both PR went up almost at same time 😅. If its possible to share how you guys found these leaks, and if theres a way to automate such auditing, I am happy to integrate as part of existing Windows workflows! |
In my use case, it's possible that new interface 'll be added after return from the 1st call to the |
There is no delay between the calls so it would be a rare incident for a third call to return a diifferent list than the second. To me this sound more like you should provide some mechanism to query the adapter list in some interval und your control. |
I am not sure, but I guess that windows are locking its device database during new device instantiation. |
The buffer must finally be released, so use a RAAI allocation wrapper to handle this (credits to [email protected] for providing a generic implementation). Also handle errors in a uniform way and use the winapi constants.
This now also contains the @scanban changes relevant to the leak fix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great set of improvements @njeisecke and @scanban!
Thanks!
Hi Esteban!
This fixes two leaks in the Windows implementation.
Thank you!