wpf性能问题
2016-07-05 16:57
295 查看
1,wpf最好使用通用模板,使用StaticResource引用样式
2,释放事件。每个UserControl,Page,Window都实现一个接口
3,定时回收垃圾
2,释放事件。每个UserControl,Page,Window都实现一个接口
interface IUIElement : IDisposable { /// <summary> /// 注册事件 /// </summary> void EventsRegistion(); /// <summary> /// 解除事件注册 /// </summary> void EventDeregistration(); }来注册事件和解除事件
3,定时回收垃圾
DispatcherTimer GCTimer = new DispatcherTimer(); public MainWindow() { InitializeComponent(); this.GCTimer.Interval = TimeSpan.FromMinutes(10); //垃圾释放定时器 我定为每十分钟释放一次,大家可根据需要修改
this.GCTimer.start(); this.EventsRegistion(); // 注册事件 } public void EventsRegistion() { this.GCTimer.Tick += new EventHandler(OnGarbageCollection); } public void EventDeregistration() { this.GCTimer.Tick -= new EventHandler(OnGarbageCollection); } void OnGarbageCollection(object sender, EventArgs e) { GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); }
相关文章推荐
- IE7降低内存和降低CPU的几个技巧
- 如何高效的使用内存
- DOS下内存的配置
- XP/win2003下发现1G的内存比512M还慢的解决方法
- PowerShell实现动态获取当前脚本运行时消耗的内存
- C#实现把dgv里的数据完整的复制到一张内存表的方法
- SQL语句实现查询SQL Server内存使用状况
- C语言内存对齐实例详解
- 深入学习C语言中memset()函数的用法
- 全局变量与局部变量在内存中的区别详细解析
- VB读取线程、句柄及写入内存的API代码实例
- php运行提示:Fatal error Allowed memory size内存不足的解决方法
- IE浏览器IFrame对象内存不释放问题解决方法
- C#之CLR内存深入分析
- JavaScript 变量、作用域及内存
- JavaScript避免内存泄露及内存管理技巧
- J2ME编程中的几个重要概念介绍
- c++实现逐行读取配置文件写入内存的示例
- Shell脚本查看进程内存真实占用情况
- w3wp.exe占用cpu过高的解决方法第1/2页