Open GazziFX opened 2 years ago
Hi, could you please provide an assembly that can be used to reproduce such an issue? I tried selecting all types under System
namespace in mscorlib
and deleting them, which was almost instant.
Maybe this can be useful https://drive.google.com/file/d/1k8vWIxtwNHdSycz7zpi-4dADfmKTpjG_
Hi, after some debugging I have found the cause of this issue. This problem's root cause is the behavior of the Treeview component when deleting nodes. When a node is removed from the tree view, the tree view component fires the SelectionChanged event. This is needed when nodes are deleted not by the user but by the application and the text viewer content needs to be updated. Every time the event is fired dnSpy recreates the text viewer content, in this case, a lot of colorful decompiled text. This event also refreshes every node's tooltip and name which causes the creation of many TextBlock
objects which applies a lot of GC pressure as well as invokes a lot of other code which is necessary to update all the information. The fact that all of this is executed for every node removal causes dnSpy to hang for an extend period of time (on my computer it took roughly 10 minutes to delete the majority of the types from the SDG.Unturned
namespace).
A potential solution to this problem would be to either optimize the actions that are done per node deletion or add some sort of special case for mass deletion where the tree view does not invoke the selection changed event for every single node and instead does it maybe for the last one. This solution is however purely hypothetical as I am not yet very familiar with how the dnSpy Tree view works.