-
Notifications
You must be signed in to change notification settings - Fork 1.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
Free transaction state upon destruction by removing pointer indirection #2663
Conversation
Wow, I can't believe I missed this. Anyway, I don't think the logic in this PR is right. We allocate a state for every instruction, so there should be a Note that when applying states we copy/re-use the list pointers, so when freeing the instruction's states we only need to free the state itself and not anything inside it. |
a75ded3
to
56e6ac2
Compare
This is more difficult than I thought it would be, so I'm not sure if this is a good solution. Also, why did you change the state to be a pointer? Can't you have a union of structs directly? |
Can you clarify why the server shutting down check is needed? I guess it would make the transaction complete instantly, which causes any destroying nodes to be freed before sway exits. I don't really see why that's useful.
I made it a union of pointers because that's what I'd seen elsewhere and didn't think too much about it. Feel free to make it a union of structs instead. |
When the server shuts down, it destroys all of the wayland clients, which create transactions to destroy the sway view, as well as the rest of the nodes. If the transactions just get destroyed, it leaves these nodes hanging around as leaked memory. If I try to force through all of the pending transactions at the end using this patch, I get this error:
The only time everything worked correctly was when I tested it with So honestly... I'm not really sure, I'm not grokking it currently, so I wouldn't mind if you wanted to have a go yourself. |
Where does Sway destroy the clients? I'm not seeing it. I also don't see why this is a problem or how it's related to this PR. If I add |
I'm happy to just add that line for now, and I'll investigate my other issue and open another PR/issue if I work out what's going on. |
Can you please make it a union of structs rather than a union of pointers? We may as well change it. |
56e6ac2
to
5de972c
Compare
I'm happy to merge this, but you still have |
5de972c
to
0dfcadc
Compare
Yes, go ahead |
Thanks! |
Fixes memory leaks.
Not sure about function names, whether to check for NULL, and commit message lol