c# - Memory leak on AddValueChanged of dependency property
问题描述
My app open and closes several times the same view and everytime it gets sluggish and sluggish as the cycle goes on. If I don't attach any handler to the ValueChanged event on my DependencyProperty, the GC collects as expected. If I add it implicitly in the declaration:
public static DependencyProperty selectedCharProperty = DependencyProperty.Register(
"SelectedChar",
typeof(Characteristic),
typeof(GenericGraphicSectionUserControl),
new PropertyMetadata(OnSelCharChanged)
);
or separately in the ctor:
TypeDescriptor.GetProperties(this)["SelectedChar"].AddValueChanged(this, OnSelCharChanged);
then the instances keep piling up. This is the closest question I could find on the matter but althout it compiles and everything, it doesn't seem to solve the problem. I also tried
TypeDescriptor.GetProperties(this)["SelectedChar"].RemoveValueChanged(this, OnSelCharChanged);
set where I'm sure the control will be unloaded but it only delays the leak by one iteration. Is there anything else I could try?
解决方案
推荐阅读
- python - 在没有源激活的情况下使用 Anaconda 环境
- r - ggplot2 线图虚线和箭头
- django - 连接rabbitmq、celery和django的通道错误
- sql - 如何计算列出了哪些表 Employee
- git - 无法使用 SSH 克隆现有或新的 git 存储库
- php - 数组计数 +1 ,网站不加载
- java - 如何在java中为以下正则表达式创建模式字符串?
- php - 将循环赛 1v1 扩展到 1v1v1v1
- rest - 在 AWS 中为基于用户的平台设计 REST API 有哪些模式?
- ionic-framework - 如何修复相机预览的预览窗口和 fab 按钮?