Hi,
this report is with no mods active, DFU 0.14.5, Windows 10.
When you stand in front of shop shelf, open it -> it adds roughly 7mb to the RAM usage.
Close it, open it again - another 7mb is added.
And this goes ad infinity.
So do it 10 times, its 70mb. Repeat it 100 times, its 700mb.. Still the same shop shelf.
I think in un-modded DFU its not a big issue and thus maybe it was overlooked, but it can possibly become a issue on a modded version with HD assets. Or maybe in a longer play sessions.
Is this a known problem? Feature? Bug?
Best regards
Possible Memory leak at the shop window
- King of Worms
- Posts: 4753
- Joined: Mon Oct 17, 2016 11:18 pm
- Location: Scourg Barrow (CZ)
- Contact:
Possible Memory leak at the shop window
DREAM Nexus https://www.nexusmods.com/users/73250038?tab=user+files
DREAM Forums viewtopic.php?f=27&t=1168
DISCORD: king_of_worms_cz
DREAM Forums viewtopic.php?f=27&t=1168
DISCORD: king_of_worms_cz
- pango
- Posts: 3359
- Joined: Wed Jul 18, 2018 6:14 pm
- Location: France
- Contact:
Re: Possible Memory leak at the shop window
Hi KoW!
Is memory reclaimed if you wait 3 minutes and open/close the shelf again?
Some resources that were released each time you closed UI windows are now only freed if more than 3 minutes have passed since the last release (PR) because it freezes the game for a short time, and often cause an annoying sound "hiccup". Just making sure release is done from time to time is sufficient to keep memory usage in check during normal gameplay.
Is memory reclaimed if you wait 3 minutes and open/close the shelf again?
Some resources that were released each time you closed UI windows are now only freed if more than 3 minutes have passed since the last release (PR) because it freezes the game for a short time, and often cause an annoying sound "hiccup". Just making sure release is done from time to time is sufficient to keep memory usage in check during normal gameplay.
Mastodon: @pango@fosstodon.org
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart
- King of Worms
- Posts: 4753
- Joined: Mon Oct 17, 2016 11:18 pm
- Location: Scourg Barrow (CZ)
- Contact:
Re: Possible Memory leak at the shop window
Hi Pango
Yes I have noticed the memory purge is happening from time to time, so that must be it.
I think this is ok solution currently. In normal gameplay, this will not be a issue and I remember that
sound hiccup from the past, which was solved by this implementation.
I think same process happens when I open inventory. If I spam open/close I see memory being filled.
But it purges after a while.
So it seems, this is a feature afterall.
Thanks for explanation/confirmation.
Yes I have noticed the memory purge is happening from time to time, so that must be it.
I think this is ok solution currently. In normal gameplay, this will not be a issue and I remember that
sound hiccup from the past, which was solved by this implementation.
I think same process happens when I open inventory. If I spam open/close I see memory being filled.
But it purges after a while.
So it seems, this is a feature afterall.
Thanks for explanation/confirmation.
DREAM Nexus https://www.nexusmods.com/users/73250038?tab=user+files
DREAM Forums viewtopic.php?f=27&t=1168
DISCORD: king_of_worms_cz
DREAM Forums viewtopic.php?f=27&t=1168
DISCORD: king_of_worms_cz
- pango
- Posts: 3359
- Joined: Wed Jul 18, 2018 6:14 pm
- Location: France
- Contact:
Re: Possible Memory leak at the shop window
Hopefully we'll find even better solutions seamlessly cleaning resources in the background. I added a comment about that some time ago, as a reminder
Mastodon: @pango@fosstodon.org
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart
- numidium3rd
- Posts: 187
- Joined: Sun Mar 25, 2018 12:34 am
- Location: United States
Re: Possible Memory leak at the shop window
This post actually got me working on a branch that proactively destroys assets before they become orphaned (i.e. memory leaks). I've made some good progress but there's a ways to go yet.
I had a thought about modding considerations. Even if I were to destroy every asset before it becomes orphaned there still would be no guarantee that all mods would follow this discipline. Currently DFU waits for a few minutes before doing a sweep so it doesn't do it too often. I think if I am able to plug all the leaks that we could make this interval adjustable or even make the sweep optional (with a warning to the user attached, of course).
I had a thought about modding considerations. Even if I were to destroy every asset before it becomes orphaned there still would be no guarantee that all mods would follow this discipline. Currently DFU waits for a few minutes before doing a sweep so it doesn't do it too often. I think if I am able to plug all the leaks that we could make this interval adjustable or even make the sweep optional (with a warning to the user attached, of course).
Nexus DFU Mods:
https://www.nexusmods.com/daggerfalluni ... user+files
Mod source repo:
https://github.com/numidium/dfu-mods
https://www.nexusmods.com/daggerfalluni ... user+files
Mod source repo:
https://github.com/numidium/dfu-mods
- King of Worms
- Posts: 4753
- Joined: Mon Oct 17, 2016 11:18 pm
- Location: Scourg Barrow (CZ)
- Contact:
Re: Possible Memory leak at the shop window
Hopefully this will be still compatible with my Dynamic paperdoll backgrounds scriptnumidium3rd wrote: ↑Sat Jun 17, 2023 7:24 am This post actually got me working on a branch that proactively destroys assets before they become orphaned (i.e. memory leaks). I've made some good progress but there's a ways to go yet.
I had a thought about modding considerations. Even if I were to destroy every asset before it becomes orphaned there still would be no guarantee that all mods would follow this discipline. Currently DFU waits for a few minutes before doing a sweep so it doesn't do it too often. I think if I am able to plug all the leaks that we could make this interval adjustable or even make the sweep optional (with a warning to the user attached, of course).
DREAM Nexus https://www.nexusmods.com/users/73250038?tab=user+files
DREAM Forums viewtopic.php?f=27&t=1168
DISCORD: king_of_worms_cz
DREAM Forums viewtopic.php?f=27&t=1168
DISCORD: king_of_worms_cz
- numidium3rd
- Posts: 187
- Joined: Sun Mar 25, 2018 12:34 am
- Location: United States
Re: Possible Memory leak at the shop window
Sure, I don't see why not. The changes shouldn't affect mods but I should do some testing before I say for sure.
Nexus DFU Mods:
https://www.nexusmods.com/daggerfalluni ... user+files
Mod source repo:
https://github.com/numidium/dfu-mods
https://www.nexusmods.com/daggerfalluni ... user+files
Mod source repo:
https://github.com/numidium/dfu-mods
- numidium3rd
- Posts: 187
- Joined: Sun Mar 25, 2018 12:34 am
- Location: United States
Re: Possible Memory leak at the shop window
I tested my new asset cleaning branch with D.R.E.A.M and found mostly pleasing results. Unity complains at me when I try to call GameObject.Destroy on modded assets so I had to create a wrapper that runs AssetBundle.Contains on them to make sure they're not loaded from a mod file. Turns out that assets in the asset database clean themselves up automatically via garbage collection. Gee, if only new'd up assets were kind enough to do that >_>........
Anyhow, I noticed in my debugging that there are still a handful of minor asset leaks that seem to be coming from D.R.E.A.M code. King of Worms, I traced a new'd up texture back to TODBackgrounds.cs. There's a relatively simple fix - when you set the background texture on line 456 with GetSubTexture, call GameObject.Destroy on that texture in the line preceding that call and that will ensure there's no dangling texture left over.
I'd be happy to take a look at any other existing D.R.E.A.M code to see if there are any leaks I could help plug. I figure since I'm doing it for DFU I might as well do it for its most popular mod.
Anyhow, I noticed in my debugging that there are still a handful of minor asset leaks that seem to be coming from D.R.E.A.M code. King of Worms, I traced a new'd up texture back to TODBackgrounds.cs. There's a relatively simple fix - when you set the background texture on line 456 with GetSubTexture, call GameObject.Destroy on that texture in the line preceding that call and that will ensure there's no dangling texture left over.
I'd be happy to take a look at any other existing D.R.E.A.M code to see if there are any leaks I could help plug. I figure since I'm doing it for DFU I might as well do it for its most popular mod.
Last edited by numidium3rd on Mon Jul 17, 2023 6:30 am, edited 1 time in total.
Nexus DFU Mods:
https://www.nexusmods.com/daggerfalluni ... user+files
Mod source repo:
https://github.com/numidium/dfu-mods
https://www.nexusmods.com/daggerfalluni ... user+files
Mod source repo:
https://github.com/numidium/dfu-mods
- King of Worms
- Posts: 4753
- Joined: Mon Oct 17, 2016 11:18 pm
- Location: Scourg Barrow (CZ)
- Contact:
Re: Possible Memory leak at the shop window
Hi Numidium
Thanks a lot for the time you spent looking at this part of the game & Dream mod. The TOD script is being developed by a friend Zoran from Nexus, I will forward him Your msg and see what he comes with. I really appreciate your offer to look into the script as well. 1st I will ask Zoran, maybe there is a reason why its solved the way currently is - so lets wait for that. He had to do A LOT of juggling around to make the TOD script compatible with other mods, and that max compatibility is crucial to us in some cases.
Lets see, and thank you once again, I will reply here as soon as know more.
PS: This is the only code in Dream, I try to have as little code in there for compatibility reasons. For the same reason, the Backgrounds will be a separate package, so its easy to disable it
Thanks a lot for the time you spent looking at this part of the game & Dream mod. The TOD script is being developed by a friend Zoran from Nexus, I will forward him Your msg and see what he comes with. I really appreciate your offer to look into the script as well. 1st I will ask Zoran, maybe there is a reason why its solved the way currently is - so lets wait for that. He had to do A LOT of juggling around to make the TOD script compatible with other mods, and that max compatibility is crucial to us in some cases.
Lets see, and thank you once again, I will reply here as soon as know more.
PS: This is the only code in Dream, I try to have as little code in there for compatibility reasons. For the same reason, the Backgrounds will be a separate package, so its easy to disable it
DREAM Nexus https://www.nexusmods.com/users/73250038?tab=user+files
DREAM Forums viewtopic.php?f=27&t=1168
DISCORD: king_of_worms_cz
DREAM Forums viewtopic.php?f=27&t=1168
DISCORD: king_of_worms_cz