I am making an openworld game for unity. I wanted to know if unity would fill up all the ram with the whole scene? If user switches to another scene what happens to the memory from the previous scene. Is it still in the Ram till garbage collection kicks in? If I destroy a chunk of my scene in my openworld game to save memory does unity give the ram back or is it still filled up?
If you create an object, that is you can see it in the Hierarchy of the scene, then it is in memory. If the camera does not see it then the rendering process is skipped but the object is still there. You save GPU process.
Even if the object is deactivated, it is still in memory but no script is run, you save CPU process.
If you destroy an object, it will remain in memory until space is required. Most likely, a new object is created and no space big enough is found, the GC kicks in to free some space.
I say most likely because even though Unity uses .NET, it also has its own garbage collector implementation in C++. I would think it works just like any other GC but it could have some slight differences on when and how things happens.