Memory leak when adding and removing nodes
vcbnm opened this issue · 2 comments
In the CodeGenApp, it appears that some memory is not being released when removing nodes. I added several 'For Loop' nodes without connecting them, then selected and deleted them again. Doing this caused the total memory usage of the application to grow.
To test, I've replaced the AutoLayout to add 100 For Loop nodes, then deleted them again manually by selecting them all.
This would increase the memory usage of the application by 400Mb, while deleting them would only free about 56 Mb. GC would not release the memory further down the line. The same issue occurs when adding the nodes manually.
The same seems to occur in the ShaderEditorApp, where adding 100 color nodes would increase memory by 110 Mb, freeing only 11 Mb after removing them.
I've tried the following to further isolate the issue:
- Created an empty viewmodel that creates a CodeGenNodeView and temporary removing the background color binding.
- In MainWindow I've removed all subscribers and initialized the instance through new, but kept the reactivecommand to add nodes.
- Removing all code from the constructor of NetworkViewModel except the initialization of SelectedNodes and DeleteSelectedNodes.
The following I've tried in my own project:
- Update ReactiveUI to 18.0.4. It appeared a known memory leak involved nested ViewModelViewHosts (reactiveui/ReactiveUI#3091). I've not tried later versions due to a change in DynamicData which prevented it from compiling.
- I've added disposers to manually dispose subscribers when removing nodes, to see if everything was working as intended. Disposables for viewmodels to dispose subscribers are called. Disposers on view are also called (when using WhenActivated).
Is it settled now? I have the same problem
Same here