开发者

TabVisible workaround - memory leaking

I'm trying to implement enhanced TabControl/TabPage classes, in order to achieve real TabVisible feature, since TabPage's Visible property doesn't work as expected.

I'm working with C# / WinForms / VS2005 / .Net FW 2.0; I've implemented the code this way:

http://csharp.pastebin.com/AUnzRQLw

And I've made a Form to test it, checking/unchecking CheckBoxes to show/hide some VisibleTabPage control开发者_如何学Gos I've added (http..//csharp.pastebin.com/MkGJGx2G). But, after a certain number of clicks on CheckBoxes, in a random sequence, the application starts to allocate more and more memory, and use some considerable amount of CPU to show/hide TabPage controls.

Can anyone point me out where is the bug?


It's a bit too much code to wrestle through. I however see you use methods like Remove() and Clear() without you ever calling the Dispose() method for a tab page. These pages get "parked" and will keep using system resources. Run Taskmgr.exe, Processes tab, View + Select Columns, tick User32 objects. You'll probably see this number going up without bound as your code is leaking the Handle for the tab page and all of its controls.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜