New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Release VRAM when switching scenes #1751
Comments
I would assume you want to remove assets from the registry, that are used by Scene after it is destroyed? Application has AssetRegistry, which holds all the information of assets and loads then when they are used in hierarchy and visible or marked as Developer might reference same asset in multiple Scene Levels, and there are complex scenarios regarding this. So, there is no clearing mechanism built in to engine, as it is Developer responsibility to manage their assets registry. One of the easiest solution for you, is using tags system:
|
Hi @Maksims Thanks for the answer. Yes, I want to remove assets from the registry, that are used by Scene after it is destroyed. Your solution with the tags is great (logic-wise), but its a lot of overhead and needs a lot of meticulousness to mark everything. That it is a developer responsibility to manage their assets registry - is a conceptual/design question. Do you know how other engines (e.g. Unity Project Tiny) handle this? It could also be designed like this: Everything is released on scene switching. If I want to keep things in RAM, I can flag it as "DontDestroyOnLoad" or something. In the end it depends on what is more common in the average projects: Assets which needs to survive through scene changes, or assets which should be destroyed on scene changes. |
Unity does not release assets when unloading scene. Assets have own registry, and not related to scene hierarchy at all.
But that would lead to someone has to mark stuff to not unload. Which can be even worse. As this implies some underlying mechanics, that developer then has to have workaround for.
From my experience, most common - is complex. If someone uses multiple scenes, then it is usually more advanced user, and has complex assets usage case. You could make a naive approach script: that would build index of all assets, then go through your scene hierarchy, and find all assets that are used, remove them from that index object. |
@Maksims Is there an equivalent solution in PlayCanvas? |
Nothing "out of the box", but if you filter by the |
Closed as there is a solution provided to get all the assets that are currently loaded. |
Feature Request: Releasing the VRAM automatically when switching scenes.
https://forum.playcanvas.com/t/vram-doesnt-get-released-properly
In our game setups, we have two root nodes, called "Scene" and "Permanent". When switching scenes, we only destroy the "Scene" node, and keep the "Permanent" node. That's similar to "DontDestroyOnLoad" flag in Unity.
Example:
-- Level Props for Level 1
-- Everything scene specific
-- Sound Manager
-- Global Logic
-- Loading Transition GUI
So it would be great to have sort of a "destroyAndFreeMemory" function for that node.
The text was updated successfully, but these errors were encountered: