Closed mike8699 closed 2 years ago
Hi! I checked this upstream in the interface code and cross-checked it with the GUI for Windows and it seems that everything is done correctly? This seems to be a general memory leak issue in DeSmuME itself then? I will mark this issue was an upstream issue, you might want to consider checking if you can reproduce this with the GUI frontends & opening an issue about this at https://github.com/TASemulators/desmume.
Actually I found a function to free the currently loaded ROM, I will add this to the interface code & to py-desmume. Still seems to me like this leak is also present in the GUIs since it doesn't seem to be used when opening a new ROM.
Opened a PR: https://github.com/TASEmulators/desmume/pull/518
Thanks for the quick action on this! I'll see if I can reproduce this with the desmume GUI and report my findings in the upstream repo.
Just to follow up on the specific use case I mentioned in the OP - since upgrading to the latest release (0.0.4.post1
as of this comment), I no longer encounter the memory leak when opening several consecutive roms. In fact, my test suite has 105 tests so far, each of which open a new rom in py-desmume, and the entire test suite runs to completion without any abnormal memory usage 🎉
I'm using
py-desmume
to assist with automated testing on my project. I have a series of pytest-driven tests that usepy-desmume
to open various NDS roms in desmume, control them, inspect their memory contents, etc. I have a singleton instance ofdesmume.emulator.DeSmuME
that I call.open(<rom_path>)
on at the start of every test.This has worked extremely well up to this point, when I had only a couple tests. However, now that the number of tests has grown significantly, I'm running into memory usage issues. Memory usage seems to continuously climb as more roms are opened, almost as if the emulator is not properly "closing" the currently running rom and freeing it from memory. I've collected some metrics below - each time entry represents a new call to
DeSmuME.open()
.I did not see any
DeSmuME.close()
method in the API docs - is there a way to tellpy-desmume
to close the current ROM and free its memory without callingdestroy()
on the entire object? If not, I think there may be some sort of memory leaking going on.