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

Sprite3Ds with fixed size, low pixel_size, large translation cause explosion in memory usage #31023

Closed
kb173 opened this issue Aug 1, 2019 · 9 comments

Comments

@kb173
Copy link

kb173 commented Aug 1, 2019

Godot version:

3.1.1

OS/device including version:

Tested on different systems with Ubuntu 19 and Windows 10

Issue description:

When spawning many Sprite3Ds with a fixed size texture and a small pixel_size far away from the origin (large values in the translation), an explosion in memory usage happens, up until the whole RAM is filled and the OS either shuts the game down, or the whole PC freezes.

From playing with the parameters, it seems to me like this doesn't worsen gradually - there's a certain threshold where the explosion starts happening, before that all is good.

Whether the explosion happens is a result of a mixture of all three parameters (translation, amount, pixel_size). In fact, with a small enough pixel_size, spawning just one Sprite3D is enough to cause the explosion!

I realize that such large values in the translation don't make sense in a real situation. However, I think the fact that this is somehow related to the pixel_size and the huge memory explosion up to an OS freeze warrant looking into this. I would at least expect the application to fail gracefully, ideally with a hint to the cause. (Debugging this was not fun!)

Minimal reproduction project:

Warning: Running this may crash your PC due to the explosion in memory - terminate the game before the RAM usage gets too high!
TextureLeak.zip

Alternative parameters with just one Sprite3D causing the explosion:

var translation_mod = 100000000
var amount_spawned = 1
var icon_size = 0.0000001
@qarmin
Copy link
Contributor

qarmin commented Nov 12, 2019

Seems like it's very deep recursion:
Zrzut ekranu z 2019-11-12 14-13-55

@Calinou
Copy link
Member

Calinou commented Nov 12, 2019

Related to #20855. Sprite3D performs a lot of work every frame, which may explain this.

@Calinou
Copy link
Member

Calinou commented Jul 6, 2020

If you can build Godot from source, please build the 3.2 branch and test this again now that #39867 has been merged. (That pull request also makes Sprite3D much faster to render.)

You can also use this Windows 64-bit editor binary for testing.

@FyiurAmron
Copy link

@Calinou I've tested it on 3.2.3 today, and it's still happening. Doesn't happen if the translation values stay in the <1E4, maybe <1E5 range (but with the value increasing, the speed visibly drops), but as soon as it hits ~1E6 range, it kills the memory completely.

@clayjohn
Copy link
Member

clayjohn commented Sep 30, 2020

@FyiurAmron it actually looks like this is more of an octree issue. In which case it may be fixed by #41123

Are you able to test on a custom build with #41123?

Cc @lawnjelly

@lawnjelly
Copy link
Member

Yes I concur, sounds like octree. Try with my PR or naithar's (linked from mine).

@FyiurAmron
Copy link

@lawnjelly do you maybe have a Win binary you could share? I have problems with building from source on my box, for a multitude of reasons. :/

@lawnjelly
Copy link
Member

Sorry I can't make one at the moment as I'm away from home this week. I would test it myself and confirm otherwise.

We should have a look at getting at least one of the octree PRs into the 3.2.4 betas soon as it is quite a nasty existing bug which needs fixing, perhaps in beta 2 (I think Akien is building the first soon).

@capnm
Copy link
Contributor

capnm commented Oct 4, 2020

t actually looks like this is more of an octree issue

I can confirm #41123 fixed the attached reproduction project for me.

@qarmin qarmin closed this as completed Oct 4, 2020
@qarmin qarmin added this to the 3.2 milestone Oct 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants