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

Various Memory Leaks #65

Closed
CasualPokePlayer opened this issue Jul 15, 2022 · 3 comments
Closed

Various Memory Leaks #65

CasualPokePlayer opened this issue Jul 15, 2022 · 3 comments

Comments

@CasualPokePlayer
Copy link

I left SkyEmu running in the background and left my laptop unattended for around 9 or so hours, and go back to it and see SkyEmu has crashed (generic 0xc0000005 exception). Not only that, but other applications seem to have crashed, like Firefox and HexChat.

Looking at the Event Viewer shows warnings on low virtual memory, with SkyEmu taking a wooping 43282735104 bytes of memory, which seems to indicate a memory leak someplace (and would explain why other applications crashed, they probably didn't like running out of memory).

@CasualPokePlayer
Copy link
Author

CasualPokePlayer commented Jul 15, 2022

A runthrough with valgrind shows multiple memory leaks. se_load_recent_games_list (main.c:465) leaks memory as an example (calls se_get_pref_path which calls SDL_GetPrefPath which returns a heap allocated string, which is supposed to be freed by SDL_free, but isn't here). Of course this extends to anything using se_get_pref_path anyways. There's also a memory leak in frame (main.c:2450) as ImFontConfig_ImFontConfig() is called, and that returns a pointer to a heap allocated instance, which frame proceeds to dereference to copy to an instance on the stack and discards the pointer, leaking memory (it should be freed with ImFontConfig_destroy).

There's probably much more, those are just some I see running valgrind for a couple seconds.

@CasualPokePlayer CasualPokePlayer changed the title Memory Leak? Various Memory Leaks Jul 15, 2022
@skylersaleh skylersaleh mentioned this issue Jul 16, 2022
95 tasks
skylersaleh added a commit that referenced this issue Jul 16, 2022
Related to issue: #65

- Cache the preference path instead of regenerating (and reallocating) each time it is needed
- Remove the path where rgba8 intermediate data could fail to get freed if there is no image slot available.
- Free ImFontConfig after finishing to construct the font.
@skylersaleh
Copy link
Owner

Thanks for finding these. I fixed those two you identified in a commit I just pushed to dev. I'll do some more triaging to identify memory leaks before 1.5 as well.

@skylersaleh
Copy link
Owner

skylersaleh commented Oct 2, 2022

Closing this for now, as I had some time to do a more thorough look for leaks and haven't found anymore. Please reopen or file a new issue if you find some more leaks.

Thanks, again for the help!

skylersaleh added a commit that referenced this issue Oct 23, 2022
Related to issue: #65

- Cache the preference path instead of regenerating (and reallocating) each time it is needed
- Remove the path where rgba8 intermediate data could fail to get freed if there is no image slot available.
- Free ImFontConfig after finishing to construct the font.
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

No branches or pull requests

2 participants