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

Using SubViewport with own_world_3d = true causes memory leak. #81476

Closed
MizunagiKB opened this issue Sep 9, 2023 · 1 comment · Fixed by #82291
Closed

Using SubViewport with own_world_3d = true causes memory leak. #81476

MizunagiKB opened this issue Sep 9, 2023 · 1 comment · Fixed by #82291

Comments

@MizunagiKB
Copy link

MizunagiKB commented Sep 9, 2023

Godot version

v4.1.1.stable.official [bd6af8e]

System information

Godot v4.1.1.stable - macOS 13.5.2 - Vulkan (Forward+) - integrated Apple M2 Max - Apple M2 Max (12 Threads)

Issue description

Memory allocated when using SubViewport with own_world_3d = true is not released when own_world_3d = false or queue_free.

The set_use_own_world_3d function is called when own_world_3d is changed.
When true is given, it seems that own_world_3d is created, but the opportunity to destroy it is not given.

Steps to reproduce

This bug can be reproduced with the following code.

func _process(delta):

    var v = SubViewport.new()

    for n in range(128):
        v.own_world_3d = true
        v.own_world_3d = false

    v.queue_free()

ss_capture

Minimal reproduction project

viewport_memory_leak.zip

@MizunagiKB MizunagiKB changed the title Using SubViewport with down_world_3d = true causes memory leak. Using SubViewport with own_world_3d = true causes memory leak. Sep 9, 2023
@TokageItLab
Copy link
Member

I investigated this a bit and it seems that the memory freeing by unref() for World3D is not working properly in the first place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants