派生 TextBox 控件的 WPF 性能问题 [英] WPF Performance Problems with derived TextBox controls
问题描述
我有一个 WPF 应用程序,它根据保存在数据库中的表单配置呈现输入表单.
表单有许多控件(100 多个),并且这些控件中的大多数是从 TextBox 控件派生的.在一些机器上(fast Hardware,Win7 32Bit,也有一些老的,Windows XP 32Bit),在输入大量这些表格后,输入性能下降.每次击键都会延迟几毫秒,解决此问题的唯一方法是关闭应用程序并重新启动它.
我的派生控件覆盖了 DefaultStyleKeyProperty
的元数据以设置自定义模板.
我目前正在 SciTech 内存分析器中重新搜索应用程序,但也许有人已经在派生的 TextBox 方面遇到过类似问题,可以给我一个提示,让我多花几个小时/天来调查问题吗?
更新
另请查看此处
听起来您可能有什么原因阻止了使用过的表单"上的控件被 GC 处理.
首先打开并使用尽可能多的表单,查看 Windows 任务管理器,看看您的内存使用情况是否在上升——如果没有,那么寻找内存韭菜就没有意义
检查您是否删除了表单/控件放置在任何长期存在的对象上的所有事件处理程序.
检查数据绑定的任何对象以实现 INotifyPropertyChanged,请参阅 KB938416>
我过去使用 Red 取得了不错的效果门内存分析器.
I have a WPF application that renders input forms based on form-configurations saved in a database.
The forms have many controls (100+) and most of these controls are derived from a TextBox-control. On some machines (fast Hardware, Win7 32Bit, also some elder, Windows XP 32Bit), after entering data to a lot of these forms, input performance goes down. Every keystroke gets a delay of some milliseconds and the only solution to resolve this is to close the application and restart it.
My derived control overrides the metadata of the DefaultStyleKeyProperty
to set a custom template.
I'm currently reasearching the app in SciTech memory profiler, but maybe someone has already experienced a similar problem with derived TextBoxes and can give me a hint and spare me some more hours/days investigating the problem?
Update
Look also here
It sounds like you may have something stopping the controls on the "used forms" being GCed.
Firstly opening and use as many forms as possible looking at the windows task manager to see if you memory usage is going up – if it is not there is no point looking for memory leeks
Check you are removing all events handlers you forms/controls have put on any long lived objects.
Check that any objects you databind to implement INotifyPropertyChanged, see KB938416
I have in the past had good results using the Red Gate memory profiler.
这篇关于派生 TextBox 控件的 WPF 性能问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!