-
Notifications
You must be signed in to change notification settings - Fork 1k
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 heap leak mentioned in #2358 #2359
Conversation
🤖 Pull request artifacts
|
Great catch! AirQualityTelemetry was based on this module as well, so it will need to be patched |
Unfortunately I overlooked one invocation of sendToPhone() in line 85 where it should now also read I just added this in an additional commit to this PR. |
There is no need to change AirQualityTelemetry because I decided to fix this issue in sentToPhone() which leaked the memory. Otherwise, if a fix had been done only in DeviceTelemetry (and AirQualityTelemetry) the interface of MeshService would look very awkward because sendToMesh() would have to be called with a copied package (because it deletes it) while sendToPhone() had to be called without a copy (because it did do a copy for itself). Now, with the change in MeshService the interfaces are more clean. It may have other side-effects, though (e.g. SimRadio which also calls sendToPhone() directly). |
I wasn't paying enough attention to your original change. Makes sense. Looks good to me |
Great catch indeed!
I wouldn’t worry too much about SimRadio. This is only used for simulating the radio on a native Linux system, so it will not be used for long consecutive periods and only on more powerful machines. I quickly checked it with the interactive simulator and this at least doesn’t break it :) |
This is a fix for #2358.
In MeshService::sendToPhone() a copy of a meshPacket is created. This copy is sent into the phoneQueue where it eventually gets deleted when fetched by the phone. The original packet is only released when it is sent over the mesh, which will not happen if DeviceTelemetryModule enters the upper branch in method EnvironmentTelemetrieModule::sendTelemetry():
The fix avoids the copying in sendToPhone(). The copying is better done in sendToMesh(), just before invoking sendToPhone():
Note: the relevant code in AirQualityTelemetryModule looks exactly the same as in EnvironmentTelemetryModule, so there should be no issue. However, I was not able to test it due to lack of such equipment.