Skip to content
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

Enabling collision increases memory consumption each time the scene is reloaded. #397

Open
easjfpjpasoepa opened this issue Jun 7, 2024 · 5 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@easjfpjpasoepa
Copy link

Terrain3D version

v0.9.1-beta

System information

Godot_v4.2.2-stable Vulkan Forward+

Is the issue reproducable in the demo?

Yes

Issue description

Each time I reload a scene with terrain placed, memory consumption increases. Disabling collisions does not cause this problem. The same problem occurred when exporting to an executable file.
https://github.com/TokisanGames/Terrain3D/assets/172058970/7bcd7477-8c79-4e1f-8a7d-46aa58bf89f9

Logs

No errors displayed in console

@TokisanGames
Copy link
Owner

Godot should free the memory if you free the scene before reloading it. We have no problem swapping out Terrain3D levels in Out of the Ashes. Collision takes a lot of memory. It will be addressed by #278.

@TokisanGames TokisanGames added the bug Something isn't working label Jun 20, 2024
@TokisanGames TokisanGames added this to the Beta 0.9.x milestone Jun 20, 2024
@liamhendricks
Copy link

I have observed this as well. I am freeing the entire scene using SceneTree.change_scene_to_packed(), but memory continues to increase on each load. I wasn't sure if my issue was Terrain3D related, but I did suspect that it was.

OP, can you provide some more details?

@TokisanGames
Copy link
Owner

You both could test debug collision, which uses a static body instead of the physics server.

You could repeatedly enable and disable debug collision in the editor and see if it leaks memory.

You can test a scene with only Terrain3D in it, or try to replicate it in the demo.

We don't use change_scene_to_packed. We have our scene loader as the main scene in the tree, which never changes. Our scene loader loads a scene, attaches it to the SL or removes and frees it.

@easjfpjpasoepa
Copy link
Author

Placing the Terrain3d node as a child of the global node solved the problem for now. Switching scenes may cause the LOD to not function properly, so you need to set up a dummy camera in Terrain3d before switching scenes and then set up an active camera in the scene after switching scenes.

@TokisanGames
Copy link
Owner

Your player and camera can also be global. Ours is. There's no need to store your player within levels, or reload them when switching. You can specify any camera at any time with Terrain3D.set_camera().

@TokisanGames TokisanGames self-assigned this Aug 28, 2024
@TokisanGames TokisanGames modified the milestones: 0.9, 1.0 Oct 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

No branches or pull requests

3 participants