Distant Terrain + Real Grass High Memory Usage

Talk about the mods or features you'd like to see in Daggerfall Unity. Give mod creators some ideas!
Post Reply
User avatar
Baler
Posts: 186
Joined: Thu May 23, 2019 1:39 am
Location: Earth

Distant Terrain + Real Grass High Memory Usage

Post by Baler »

Pre-text, recently I discovered my DFU was using 10+ gbs of memory, this freaked me out and I started loading mods in groups of 5 to see which mods were causing this. Here is what I discovered.

Distant Terrain without real grass barely uses extra memory
Real Grass without distant terrain does manage memory usage, albeit a lot of memory as expected.
Distant Terrain + Real Grass = Memory hog that grows in size.

Tested with DFU version Beta 0.11.1

steps to reproduce
(monitor your DFU memory usage with task manager)
1. DFU Beta 0.11.1 + Distant terrain + Real Grass installed
2. load a saved game or start a new game
3. Fast Travel to any town/city
4. Continue fast traveling to different towns and watch your memory usage climb

I tested this with a brand new clean install of daggerfall unity, clean appdata folders & clean mod installs. Just to make sure there was no other variables affecting this.
Distant Terrain Nexus
Real Grass Nexus

I don't have a solution for this problem, Maybe someone has some idea of what's going on here. :|
Also i'm not trying to point fingers and blame anyone, these are two great mods but there seems to be a conflict.
DFU Discord Link: http://discord.gg/HXMrKU6

User avatar
Nystul
Posts: 1481
Joined: Mon Mar 23, 2015 8:31 am

Re: Distant Terrain + Real Grass High Memory Usage

Post by Nystul »

What happens if you just run RealGrass mod but with maximum terrain distance of 4 instead of 3?

Does it also happen if running both mods with lower terrain distance in the settings?

User avatar
TheLacus
Posts: 1322
Joined: Wed Sep 14, 2016 6:22 pm
Contact:

Re: Distant Terrain + Real Grass High Memory Usage

Post by TheLacus »

I expect memory usage to be proportional to terrain distance (specifically to the number of Unity terrains around players) and the number of layers enabled in settings (grass, flowers, stones...). Each layer has a map to define where meshes should be positioned on terrain; these maps can take a singificant amount of space if you consider all layers for all terrains.

A possible workaround is to add grass only to the nearest terrains even if higher terrain distance is enabled. However this has possible negative consequences, like freezes when you move, because this process of adding and removing grass needs to be performed in the background. Effectively freeing memory is also not trivial; it would need to rely on Unity/C# garbage collection and this takes its own time. Right now it's only performed when you fast travel or similar situations, but doing it every time you move a few terrain tiles might not be viable for performance.
Mod System documentation - Learn how to create mods for Daggerfall Unity.
Modder Discussion - General help and discussion for the mod system.
Github Issues - Submit a bug report for the game, including the mod system.

User avatar
Baler
Posts: 186
Joined: Thu May 23, 2019 1:39 am
Location: Earth

Re: Distant Terrain + Real Grass High Memory Usage

Post by Baler »

Nystul wrote: Mon Mar 15, 2021 12:25 pm What happens if you just run RealGrass mod but with maximum terrain distance of 4 instead of 3?
Tested with a clean install of daggerfall unity beta 0.11.1 with terrain distance 4
Same results as before, with Just real grass it does manage the memory usage.
Here is me not moving, on a fresh character traveling to 6 cities, no settings changed and terrain distance 4 in dfu settings.
3,059,088
3,056,364
3,027,812
3,108,392
3,561,964
3,210,180
Nystul wrote: Mon Mar 15, 2021 12:25 pm Does it also happen if running both mods with lower terrain distance in the settings?
(Load Order Distant Terrain First, Real Grass Second)
1,444,540
1,824,712
2,291,960
3,038,376
*2,107,780 (note: the memory dropped on it own before I traveled)
2,464,004
3,063,600
3,791,012
4,560,096
I stopped and waited a few minutes to see if it would manage the memory.
When I opened the world map after a few minutes. Daggerfall's memory clearer kicked in. You know the one that people were complaining about before because it happened everytime you opened a menu, before.
*1,802,492 (standing around after opening the world map)

Note in both tests I started brand new games, I didn't load a save.
I never moved my character, looked around or opened any menu's other than the world map for fast travel

So a few things of interest here,
DFU's Terrain Distance does affect how much memory Real Grass uses.
Daggerfall Unity's memory clear function is working as intended.(this is good)
But there is still something going on between distant terrain and real grass that causes it to climb in usage.
As seen by the first test with just real grass on terrain distance 4, it was managing how much memory it used after each fast travel to major cities.
I also tried the load order of real grass first and distant terrain second, no change.
TheLacus wrote: Mon Mar 15, 2021 4:13 pm I expect memory usage to be proportional to terrain distance (specifically to the number of Unity terrains around players) and the number of layers enabled in settings (grass, flowers, stones...). Each layer has a map to define where meshes should be positioned on terrain; these maps can take a significant amount of space if you consider all layers for all terrains.
This is reasonable and based on the data I found, this seems to be true.
TheLacus wrote: Mon Mar 15, 2021 4:13 pm A possible workaround is to add grass only to the nearest terrains even if higher terrain distance is enabled. However this has possible negative consequences, like freezes when you move, because this process of adding and removing grass needs to be performed in the background. Effectively freeing memory is also not trivial; it would need to rely on Unity/C# garbage collection and this takes its own time. Right now it's only performed when you fast travel or similar situations, but doing it every time you move a few terrain tiles might not be viable for performance.
Since daggerfall's memory clearing function seems to work, What about attaching it to clear memory after every fast travel, in addition to it's normal every few minutes. Or is this a really dumb idea?
DFU Discord Link: http://discord.gg/HXMrKU6

Post Reply