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

Memory leak(?) when using "Creation CollisionPolygon2D Sibling" #35468

Open
soyrandom1 opened this issue Jan 23, 2020 · 3 comments
Open

Memory leak(?) when using "Creation CollisionPolygon2D Sibling" #35468

soyrandom1 opened this issue Jan 23, 2020 · 3 comments

Comments

@soyrandom1
Copy link

soyrandom1 commented Jan 23, 2020

**Godot version: 3.1.2 stable win64 **

OS/device including version: Windows 10

Issue description: I was playing arroun with the "create CollisionPolygon" sprite tool. I generated one with lots of points, so godot and my game got very laggy. (I did some tests before with more simplification and my program worked fine). Then i went back to the more simplified version of that collisionPolygon but when running my game it was very slow. The game was using arround 500mb of memory. I was super lost, because it worked fine and now it was laggy. I restarted my pc and the game went back to normal (arround 25/30mb of memory usage), so i'm pretty sure this is a memory leak.

Steps to reproduce: from an sprite, use the "Create CollisionPolygon" (i have the spanish version, it says something like "create brother of (or for) collisionPolygon2D", i'm not sure about the exact name in english); then at simplification use the default value (2). Attach some movement code to that sprite so you can see if it lags. (spoiler alert, it doesn't). Now generate that collisionPolygon again but at simplification use some ridiculous value like 0.3, run the game, it's going to be laggy (if not, use a lower value). Then generate it again with the first value (2), run the game and you will see it lags a lot.

Minimal reproduction project: I really don't have time to do a demo file rn, sorry!

@YeldhamDev
Copy link
Member

Can you reproduce this in the newest release candidate?

@soyrandom1
Copy link
Author

Can you reproduce this in the newest release candidate?

i'll try and also i'll include an example file as soon i have some time, maybe tonight

@tom-jk
Copy link

tom-jk commented Jul 16, 2020

Tested in Godot 3.2.2.stable on linux mint 18 with this test project: 35468.zip

Steps to try:

  1. load project
  2. select sprite, "Create CollisionPolygon2D Sibling" (with any high-complexity settings, like simplif' 0.01, shrink 3, grow 6)
  3. reload scene
  4. repeat 2 and 3

Godot editor gains maybe a megabyte or two every one or two repeats. Doing it without making collision siblings (eg. load scene, toggle sprite visibility, reload scene, repeat) shows no apparent gain (when viewing size in megabytes to 1DP).

So, memory used for collision shapes (or generating them) does seem to hang around (but of course that could just be leftover pool or something rather than leak). Godot reports no leaks/orphans/etc. in terminal on exit (running with --verbose).

Godot does get laggy when you have complex/many collisions shapes, as you'd expect (lag in the game is interesting though - when moving, it can move fairly smoothly (depending on amount of collision of course), but when you release all keys then press one to move it pauses for about half a second). Things go back to normal speed in both editor and game once collisions are deleted or the scene is reloaded.

Problem in practice? Well for me, lag grows to unworkable levels long before godot could leak enough memory to be an issue, so... I guess if you're working in a single editor instance for weeks and are doing these operations a lot?

(Note: included project also includes a Node2D with a toggle in the inspector to print stray nodes. You can see the list grow if you make, delete, re-make collision siblings over and over - but it returns to normal when you load the scene afresh. I think that's expected.)

(Curiosity: it takes about two seconds to generate collisions, but minutes to delete them 😶 reload scene is still fast though)

@akien-mga akien-mga changed the title Memory leak(?) when using collision polygons Godot 3.1.2 Memory leak(?) when using "Creation CollisionPolygon2D Sibling" Oct 24, 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

5 participants