Hi all!
I have a large world and a system that spawns game objects (from now on: “decorations”) and terrains around the player according to the position of the player.
Previously all existing terrains prefabs were assigned to a scriptable, while decoration prefabs were assigned to a different scriptable. Both scriptables were loaded with Resources.Load soon after the launch of the game. This caused all the prefabs and their linked assets to be loaded into the memory at once, leading to high ram usage.
Now all these prefabs have become addressables and have been added to 2 different addressable groups, while the scriptables contain a list of AssetReference instead of a list of GameObject. When the system must spawn a decoration or a terrain, it loads the asset reference into memory with Addressables.LoadAssetAsync, then spawns the GameObject with GameObject.Instantiate. If an AsyncOperationHandle for the same asset already exists, the system uses the loaded asset (if ready) or enqueues the spawn until it’s ready, so there can’t be more than 1 handle for the same asset.
If all the game objects generated from the same asset have been destroyed, the system releases the handle with Addressables.Release.
The system works well - initial memory usage is much, much lower. Sadly, it grows slowly over time when the player moves around, as if the assets no longer needed and unloaded where actually never removed from the memory.
What is causing that? Is it not enough to destroy all the gameobjects and call Addressables.Release on the handle? Or is it the fact that all the decorations / terrains belong to the same group, thus the same asset bundle, and an asset bundle can be partially loaded but not partially unloaded?
If the reason is the latter, what’s the right approach? Split the 2 bundles into multiple bundles based on the region of the world in which the assets are needed?
Thank you!

