Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

On occasion my app begins to consume maximum CPU and the GUI becomes unresponsive. Maybe 1/50 attempts to reproduce this succeed.

Based on the high CPU usage it obviously is running (not blocked externally) but I'm not sure how to identify in the debugger where the execution is taking place.

The scenario of this problem goes like this:

  • App starts
  • User causes new modal window to open
  • User works in this window for a while
  • Eventually the window "freezes" (sometimes)

It is this last event which I am trying to debug.

I have followed the advice in Find infinite loop in progress? but when I break in the debugger it just lands on this line:

return f.ShowDialog();

I'm not sure why this is what the debugger considers to be the current executing line. I am not creating any threads.

Is there any way to debug this situation in the context of a modal window?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
141 views
Welcome To Ask or Share your Answers For Others

1 Answer

Thanks to people who commented, this was the approach that turned out to be successful. Or at least, it shed some valuable light on the issue:

  • Run the app until the problem occurs

  • Run Process Explorer and find the app's process

  • Open the properties window for that process

  • View the threads which are running and identify which one is using all the CPU.

  • View the stack trace of that thread

In my case, I could see that in the stack trace nearly all the time is being spent inside functions in wpfgfx_v0400.dll, mostly in functions Utility_PolygonBounds or Utility_PathGeometryBounds.

enter image description here

I'd also set zillions of breakpoints in any WPF-related code / code-behind, and none of them are hit. So it really seems to be getting stuck inside that library. I have posted a separate question specifically about that issue: App frozen inside wpfgfx_v0400.dll Utility_PolygonBounds and Utility_PathGeometryBounds?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...