Odd performance degradation in application
We have an application that is mixed .NET 2.0 and native C++. In our testing, we have a mode which can automatically loop through a set of projects. A project opens, runs, closes, repeat. Each of these steps requires creation/destruction of windows (winforms to be precise). Recently we've experienced some odd behavior in performance. After running for a few hours the opening and closing parts slow down (blocking the gui thread and showing half drawn screens etc). Now it would be easy to chock this up to a resource leak...but we're tracking handles and memory, and while memory grows slightly there's nothing to indicate this level of proble开发者_如何学编程m. Handles are stable. So maybe dangling event handlers...still need to investigate that. But the kicker, which perplexes me, is that shutting down the application and restarting it doesn't bring back the initial performance. It's still slow until I reboot the OS (win XP) and then performance starts out snappy again. This really perplexes me as I assume shutting down the application will reclaim all resources. Any thoughts?
Sounds like a possible GDI handle leak. GDI objects are not automatically picked up by the Garbage Collector.
.NET Memory Profiler (http://memprofiler.com/) does a good job of tracking these (there is a 14 day trial version).
Have you seen these:
Resource Leaks: Detecting, Locating, and Repairing Your Leaky GDI Code
Detect and Plug GDI Leaks in Your Code with Two Powerful Tools for Windows XP (has a link to a GDI Handle viewer tool).
You're assuming its a resource leak (which isn't a bad guess), but it might be something else.
Have you tried using a performance profiler?
We were leaking window classes
精彩评论