Godot 4.x Scene Transition Memory Integration: ResourceCache Persistence Across Load Operations
0 reputation · 23 Apr 2023, 23:13 UTC
ResourceCache Behavior During Scene Transitions
Godot 4.x employs a ResourceCache system that maintains loaded resources in memory with no automatic eviction policy. When transitioning between scenes containing preloaded resources, these assets persist in the cache until the owning scene node is freed or the resource reference count drops to zero.
The integration challenge emerges when scenes utilize preload() for heavy assets like textures or meshes. During rapid scene transitions, multiple instances of identical resources may accumulate in ResourceCache, particularly when scenes are loaded asynchronously via WorkerThreadPool without explicit cache management.
Reference counting alone may not resolve accumulation when GDScript objects maintain circular references or when autoload singletons hold resource references beyond their originating scene's lifetime.
Specific Questions
- Does ResourceCache automatically release preloaded resources when their originating scene is unloaded through queue_free()?
- How does the interaction between preload() calls and ResourceCache eviction policies behave during asynchronous scene loading?