stride3d / stride

Stride Game Engine (formerly Xenko)
https://stride3d.net
MIT License
6.33k stars 917 forks source link

Editor Scene Hierarchy Memory Leak #2268

Open IXLLEGACYIXL opened 1 month ago

IXLLEGACYIXL commented 1 month ago

Release Type: Official Release/GitHub (please choose appropriate option) 4.2

Describe the bug The Editor has a memory leak in the assethierarchy or something that is connected to it

To Reproduce Steps to reproduce the behavior:

  1. new standard project
  2. watch at your mb used ( around 300 )
  3. click through the scene hierarchy, order doesnt matter, just click on items in the scene hierarchy in random order
  4. swapping 4 times the item in the hierarchy , the usage goes up by 12mb and stays at that level

Expected behavior The memory usage shouldnt just increase by clicking in the scene hierarchy

Screenshots grafik grafik

Eideren commented 1 month ago

This image shows some of the instances retained after selecting two different assets: image AssetRootNodePresenter seems like a good start, it likely is rooted somewhere and prevents its references from being collected. Here are the root paths for one of the two retained AssetRootNodePresenter: image So, all of the links to the node at the top should have released their reference to it but haven't for some reason. I don't have time to look into it further than this right now, so I'll leave it for now

Kryptos-FR commented 1 month ago

We have a previous/next system (based upon the undo/redo stack) which records selection of items in asset view or in scene hierarchy, so it is expected to have slight increase in memory when changing selection.

IXLLEGACYIXL commented 1 month ago

the memory increasse is 6-7mb per click in the hierarchy, i didnt click often to reach 1gb of memory

it would make more sense to release the UI on click and on undo go back to the previous UI and build the UI again overall in gamestudio its a problem that nothing is getting released

Kryptos-FR commented 1 month ago

it would make more sense to release the UI on click and on undo go back to the previous UI and build the UI again

I have no idea what you mean by that.

IXLLEGACYIXL commented 1 month ago

lets say the method exists "BuildUiOnHierarchyClick"

currently you click, BuildUiOnHierarchyClick(target) runs, you click again, the UI gets stored in the undo command

instead of storing the entire UI in the UI command you can just store BuildUiOnHierarchyClick(previousTarget) , so if you undo you build the previous UI again, instead of storing the entire UI

Kryptos-FR commented 1 month ago

There is no such thing, that's not how the undo/redo system works. It doesn't store anything related to UI.

Kryptos-FR commented 1 month ago

With that said, the leaks are likely not in the scene editor itself but on the property grid (and/or quantum nodes). I can reproduce an increase in memory by switching between selecting a Scene asset and the GameSettings asset in the asset view.

IXLLEGACYIXL commented 1 month ago

With that said, the leaks are likely not in the scene editor itself but on the property grid (and/or quantum nodes). I can reproduce an increase in memory by switching between selecting a Scene asset and the GameSettings asset in the asset view.

a slight increase would be reasonable but 7mb per click is a little bit too much