Almost all the memory consumption was due to the Texture Sizes. We had 4k textures with more than 40mb in the VRAM, without any sense.
I did some tests with the following steps
Open Godot
Go to Genesis City
Wait to load everything
And the results were:
Without any resize:
Resizing to 256x256 all the textures from fetch_texture
Resizing to 256x256 all the textures from fetch_texture and all textures in GLTFs
With this result. We implemented a Texture Quality Setting, to have multiple quality of texture with the following table
QUALITY
MAX SIZE
LOW
256x256
MEDIUM
512x512
HIGH
1024x1024
SOURCE
INFxINF
To free memory, we added a reference counter to all the resources, and when they have not been accessed for the last 30 seconds, and the reference count is just retained by the cache, we release them.
Almost all the memory consumption was due to the Texture Sizes. We had 4k textures with more than 40mb in the VRAM, without any sense.
I did some tests with the following steps
And the results were:
Without any resize:![image](https://github.com/decentraland/godot-explorer/assets/12563266/8aae65b8-01d8-435a-83a6-07c3f1b2765b)
Resizing to 256x256 all the textures from fetch_texture![image](https://github.com/decentraland/godot-explorer/assets/12563266/c2c646d9-2912-452a-b908-945b99b4f8f0)
Resizing to 256x256 all the textures from fetch_texture and all textures in GLTFs![image](https://github.com/decentraland/godot-explorer/assets/12563266/83cd17ee-bbb3-40a1-aace-437937e17c6f)
To free memory, we added a reference counter to all the resources, and when they have not been accessed for the last 30 seconds, and the reference count is just retained by the cache, we release them.
All that work is in the following PR: https://github.com/decentraland/godot-explorer/pull/414