Skip to content
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

Rewrite menu code to track memory usage, prevent crashes and fix leaks #137

Merged
merged 4 commits into from
Sep 19, 2024

Conversation

Rackover
Copy link
Contributor

The biggest paradigm change is that menus are now overriden from raw when the filesystem is reloaded during a UI_Init or CGameStart. They are no longer loaded on demand, they are always loaded when present.

Normally we should use menu lists (like code.txt ) for this, it would be the correct approach.
However this would instantly break decades of mods and servers, so right now I can't consider it. There's a little trick instead to make sure we only load stray menus when in game, and not in the main menu (where most would fail anyway), so mods that modify the main menu will have to have a menulist TXT somewhere to say what should be loaded and what shouldn't.

Copy link
Contributor

@diamante0018 diamante0018 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to compare it against the code that I wrote on IW4x-SP.

Until I did all the memory DEAllocation code I could note a memory increase after every single map rotate when I had custom menus loaded from RAW which is what you seem to be reporting in the discord channels. I believe this is still tied to a menu memory leak.

https://git.alterware.dev/alterware/iw4x-sp/src/branch/master/src/client/component/ui.cpp

src/Components/Modules/Menus.cpp Outdated Show resolved Hide resolved
src/Components/Modules/Menus.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@diamante0018 diamante0018 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You seem to unnecessarly Include the components namespace when invoking the logger. (a copy paste from the zone/asset code) You are already in the components namespace most of the time so it's not needed

src/Components/Modules/Console.cpp Show resolved Hide resolved
src/Components/Modules/QuickPatch.cpp Outdated Show resolved Hide resolved
@diamante0018
Copy link
Contributor

btw this is how guy debugs SL and Memtree now: https://gist.github.com/ineedbots/ccd66cf076e67b6033bea8fb8d965bc8

@Rackover
Copy link
Contributor Author

I've tested it, so I'm merging and releasing it right now because this addresses a very frequent crash. I will open another pr for next changes if needs be

@Rackover Rackover merged commit 541c671 into develop Sep 19, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants