Describe the bug
For many controls, you are subscribing to events (+=) in the constructor using lambdas or without any destructors (-=). These event subscriptions are going to make the objects unavailable for garbage collection. In the case where lambdas are being used, those should be replaced with concrete handler methods because lambdas cannot be unsubscribed.
To solve this issue, you should consider using weak event subscriptions or adding/removing handlers as part of a control's lifecycle, such as during OnHandlerChanging or OnHandlerChanged.
To Reproduce
Steps to reproduce the behavior:
Create an AdvancedEntry
try to garbage collect it.
Expected behavior
Controls should be available for garbage collection.
Describe the bug For many controls, you are subscribing to events (
+=
) in the constructor using lambdas or without any destructors (-=
). These event subscriptions are going to make the objects unavailable for garbage collection. In the case where lambdas are being used, those should be replaced with concrete handler methods because lambdas cannot be unsubscribed.To solve this issue, you should consider using weak event subscriptions or adding/removing handlers as part of a control's lifecycle, such as during
OnHandlerChanging
orOnHandlerChanged
.To Reproduce Steps to reproduce the behavior:
AdvancedEntry
Expected behavior Controls should be available for garbage collection.
Additional context Handler Lifecycle
Weak Event Manager
Here is an example of how it could be changed for
AdvancedEntry
.