Emulator Issues #8738
After loading multiple times savestates, Dolphin takes a huge part of memory
[READ THIS: https://forums.dolphin-emu.org/showthread.php?pid=276132 <<<
Your answers are there!]
[Leave the questions as they are and answer them in the next line]
[Remove lines written inside brackets , but nothing else]
What's the problem? Describe what went wrong in few words.
When I load like 50-60 times savestates, Dolphin starts to lag a lot, and takes a high memory (sometimes it can uses 2,5GB of memory)
What did you expect to happen instead?
Dolphin don't take a lot of memory
What steps will reproduce the problem?
[Don't assume we have ever played the game and know any level names. Be as
specific as possible.]
1.Launch a game
2.Load a lot of time savestates
Dolphin 3.5 and 3.5-367 are old versions of Dolphin that have
known issues and bugs, so don't report issues about them and test the
latest Dolphin version first.
Which versions of Dolphin did you test on?
I tested this on last Dolphin version
Does using an older version of Dolphin solve your issue? If yes, which
versions of Dolphin used to work?
I tested also on 3.0-1749, and it didn't made this.
What are your PC specifications? (including, but not limited to: Operating
System, CPU and GPU)
Is there any other relevant information? (e.g. logs, screenshots,
[Upload big files to a hosting service and post links here!]
Nothing, I'm gonna test Dolphin versions to see at around which versions it does this :p
Thanks for taking your time to fix glitches :)
[Do not attach files to this issue. Upload them to another site and
link here. Use imgur.com for images and pastie.org for logs. Monitor the
email address that was used to create this issue.]
#9 Updated by hk.konpie over 5 years ago
I analyze a bit those unordered_map, it's result have 2 problem.
1. When load state, not consider these.(this issue, one of the causes)
Most games are around several MB.
(specification implement jit? a tacit understanding since several years?)
2. Regardless load state, it enlarged steadily by specific game.
for exmaple, The Last Story(SLSJ01).
(Last Story start, leave anything without play it. And disconnect wiimote guidance. Monitoring dolphin process memory.)
Sorry my bad English.
#13 Updated by moncef.mechri about 5 years ago
I cannot reproduce this issue on Archlinux x86_64.
I made saves of Smash Bros Brawl using the Fn keys and tried to load them many times while monitoring the memory usage in htop. The loading works fine but I don't see any change in memory consumption.
And I did try both a Debug build and a Release build
#15 Updated by JosJuice about 5 years ago
The memory usage increases when loading a savestate and then letting Dolphin run for a second or so. It doesn't happen when loading savestates when Dolphin is paused. This fits with what hk.konpie found - the JIT is only adding entries to the unordered_maps when it's running.
#16 Updated by hk.konpie about 5 years ago
In my #7 comment
- Regardless load state, it enlarged steadily by specific game. for exmaple, The Last Story(SLSJ01).
Have no relationship to this issue8738.
This was due to another.
(The cause was dcbi instruction in LCDisable. LCDisable is executed every 1fps, maybe. As a result, exception handler(JIT_PPC_00000xxx) is generated repeat every 1fps. This seem bug to me. Another for example, Tower of Pandora(SX3J01), ONEPIECE UC EP1(ROUJAF)&EP2(RIUJAF).)
#17 Updated by JosJuice almost 5 years ago
HdkR looked into this today and reproduced it on Ubuntu. Some of the conclusions:
(15:27:18) HdkR: I'm also 100% sure that it isn't an issue with our block cache
(15:33:47) Fog_TAS: hmm
(15:33:52) Fog_TAS: where does that leave us?
(15:35:48) HdkR: Iunno
(15:36:07) HdkR: Figure out what is leaking the memory instead of blaming the block cache?
(15:37:18) Fog_TAS: I'm guessing the unordered_map was the block cache
(15:37:20) Fog_TAS: ?
(15:37:24) JosJuice: Should be somewhere in the JIT code at least, since there were reports that it doesn't happen with interpreter
(15:38:00) HdkR: JosJuice: Or that they didn't wait long enough between state loads to see it
(15:38:05) JosJuice: Also possible
(15:38:27) JosJuice: Yeah, now that I think about it, that doesn't sound unlikely at all
(15:38:38) HdkR: If it is something on the GPU then I wouldn't be surprised
It also seemed like the memory usage was increasing faster when EFB to RAM was used. Please correct me if I missed something important.
#19 Updated by Fog almost 5 years ago
These unordered_maps should originally clear it after ClearCodeSpace().
sample patch (but very old): http://pastebin.com/qJXU5KBP
Sorry my bad english from japan.
English is fine, no need to worry.
Anyways, I've tested the patch and it mitigates the expanding RAM usage (clears it once it reaches a certain point) but doesn't solve why it's actually growing. However, it's better than nothing.
#21 Updated by Fog almost 5 years ago
but doesn't solve why it's actually growing.
Do you try insert JitInterface::ClearCache() in State.cpp?
I actually cleared the cache within JitInterface instead, just put my pull request up here: https://github.com/dolphin-emu/dolphin/pull/3535