-
Notifications
You must be signed in to change notification settings - Fork 87
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 memory leaks #873
Fix memory leaks #873
Conversation
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.
See notes, and also we have tests for memory leaks, but we missed this leak.
So we need to add a test that checks it, especially considering the complexity of the fix.
} | ||
_z_msg_clear(msg); |
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.
It looks dangerous that we are now clearing messages not for all types, are all variants taken into account _Z_N_PUSH for example?
Perhaps, if we don't need clearing for some specific type, it would be better to explicitly write about it, or even make a skip_clean flag and set it for a specific type, while leaving the clearing at the end as it was before.
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.
See the comment for the _z_t_msg_clear.
break; | ||
} | ||
|
||
default: { | ||
_Z_ERROR("Unknown session message ID"); | ||
_Z_ERROR("Unknown transport message ID"); | ||
_z_t_msg_clear(t_msg); |
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.
Here and for multicast the same.
Why we can't just call _z_t_msg_clear at the end of method without increasing code complexity?
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.
The initial solution was something like this but it's more efficient to only delete what's needed + the small bonus that we don't need to parse the header again, which on high throughput starts to become significant. Problem is that's only known further down the line by specific functions.
I think the better solution is to have, for each case, a dedicated functions that processes each message type and to leave the decision to clear or not to them. It will be neater code too. Actually I was planning to do this in a follow up PR.
Fixes #861 and an additional leak related to lru cache.