-
-
Notifications
You must be signed in to change notification settings - Fork 687
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(server): fix leakage of SessionMetaData #728
Conversation
@tw4452852 Thanks for catching this! I'm a bit curious about how big of an issue this is and whether there is an alternate approach to solve this. This only happens when zellij is exiting and IIUC the OS releases any memory allocated to a process after it exits. The reason I'm concerned is that the new change adds polling to the thread so the thread will wake up every 10ms. We had a similar polling approach in some other section of zellij in some of the earlier releases due to which users complained of higher CPU and power consumption (Linked Issue: #509). |
Hi @kunalmohan Indeed, any allocated memory will be released by the OS when the process exits. But as I did some temporary files cleanup in PR #723 when zellij/zellij-server/src/lib.rs Line 106 in 72b0474
Also if we add more actions when threads exit in the future, this really needs to be fixed I think. Regarding the CPU usage when polling, it's almost ignorable compared to the blocking mode. As I use this during my daily work. |
I hope it's okay if I chime in here: if this is in order to facilitate something else that hasn't been merged yet, maybe we can look into that first and then see if we still need this one? I guess @TheLostLambda will probably have some useful input regarding cached plugin disk metadata. |
FWIW we drop the zellij/zellij-server/src/lib.rs Line 270 in 72b0474
But there are other cases where we don't drop it on exit (this and this). So maybe we can move the above statement outside the loop, before: zellij/zellij-server/src/lib.rs Lines 300 to 304 in 72b0474
|
Ah, I see! |
@kunalmohan zellij/zellij-server/src/lib.rs Lines 167 to 187 in 72b0474
Correct me if I'm wrong. |
@tw4452852 yes, you are right! |
There are different reasons leading the server thread exits, currently we only release the cached session data when client exits normally. This fix covers all the cases. Signed-off-by: Tw <tw19881113@gmail.com>
a1972ed
to
d857b5a
Compare
Thanks @kunalmohan I have updated the patch according to your suggestions. |
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.
LGTM! Thanks!!
Currently, when the server exits, Session data is leaked because 'server_listener' thread still holds a reference to it.
Due to this thread blocking on the socket accepting, to fix this problem, we change it to polling mode (the timer interval is 10 milliseconds) and add a flag to indicate exit.
Signed-off-by: Tw tw19881113@gmail.com