I am working with Subscenes conversion in Unity 2019.1.11 and I can’t seem to find an answer for how resources are managed in ECS.
Test 1
SampleScene.subscene contains 3 GameObjects, with a MeshRenderer component in each passing a different mesh per object (3 meshs total).
I’ve created a Subscene and had it be automatically loaded, under a parent Main.scene. I’ve created a system using Jobs to add ResquestSceneLoaded and remove RequestSceneLoaded from the scene entity. Each scene entity contains MeshRenderers only.
When looking at the EntityDebugger, I was able to see all my entities (with the exception of the parent one) being unloaded. However, when looking at the profiler, I’ve noticed the number of meshes in memory is still 3 and it does not decrease, which suggests the resources are not unloaded.
Test 2
Same setup as above. This time, I’ve placed each Subscene object inside a .scene. I went back to the Main.scene and added a script that calls LoadSceneAsync and Unload targeting a parent scene containing a subscene object converted to entity (LoadingMode Additively).
The entity debugger results show that the parent entity is now also removed when unloaded. However, in the profiler, the mesh count is still 3 after the unloading. The garbage collector does not seem to be picking up and freeing the meshes from memory.
Test 3
Went one step above in hierarchy and unloaded the whole Main.scene, and loaded another scene on its place.
As expected, entity debugger displays no entities. The profiler, on the other hand, still shows Mesh count as 3 in memory, with no action from the garbage collector.
Question
Is there something I am missing here? If this is the expected behavior, how are we supposed to manage these resources when working with ECS?