Thanks to @Vision Pro Engineer answer, I could find the solution!
I tried checking for others references to the entities added in the ImmersiveSpace. Indeed, I could find some references and auxiliary entities that were not being explicitly removed from parent on dismiss. Also, I made sure to remove the rootEntity from the parent as I was not doing it before (I thought that removing the entities themselves would be enough).
It worked! Now the memory almost goes back to the state before the ImmersiveSpace was opened.
However, I did had to:
force the .removeFromParent() for each non-nullable entities (MOST RELEVANT) ;
reset the arrays and dictionary referencing entities to [] or [:];
nulling every reference for Textures, EnvironmentResources and Colliders etc (LESS RELEVANT);
I think that this should not be the expected behavior. I guess that most developers would assume that this clean up is supposed to be automatically made when the ImmersiveSpace is dismissed and/or when the RealityView is dismissed.
But thanks a lot for the help!
Topic:
Spatial Computing
SubTopic:
General
Tags: