11

I'm working on MDI application written in C++ Builder 2010. When child window is in maximized state, application consumes 100% of CPU time in idle mode.

I have used 'Very Sleepy' profiler and it shows that function Sd_childFinalize is using 99% of CPU resources but I can't find it in my code. sd_Child.cpp is the C++ unit where MDI child form class is defined. I only found @@Sd_child@Finalize symbol in executable file. Please help me to understand how to debug this issue.

Yury Rudakou
  • 411
  • 3
  • 15
  • Why are you still using MDI in 2012? It was deprecated long, long ago. – Mason Wheeler Sep 25 '12 at 18:21
  • I've seen this before in Delphi. Off the top of my head I cannot recall any details. – David Heffernan Sep 25 '12 at 18:23
  • `sd_Child.cpp` is not part of the standard C++ Builder install on my machine, and just like `MDI` refers to `Multiple Document Interface`, `SDI` usually refers to `Single Document Interface`, which wouldn't be part of an MDI application framework. Are you using a third-party package of some kind? – Ken White Sep 25 '12 at 18:32
  • @Ken White sd_Child.cpp is application unit, not part of the VCL. – Yury Rudakou Sep 25 '12 at 18:52
  • @Mason Wheeler I maintain project based on MDI architecture. – Yury Rudakou Sep 25 '12 at 18:59
  • 3
    Is this a related question?: [MDI app with ActionMenus uses 100% CPU when maximized](http://www.delphigroups.info/2/fd/290887.html). – LU RD Sep 25 '12 at 20:05
  • 2
    @Mason MDI might be deprecated by MS, but it's still used. My app is an MDI app. I could change, but I think that would irritate my clients. – David Heffernan Sep 25 '12 at 20:44
  • @Mason, I can't imagine serious graphics editor without MDI. Hunting tens of images all over the screen would be painful (one of the main reasons why I don't like GIMP). – TLama Sep 25 '12 at 21:19
  • 2
    @TLama you can do MDI like app without using MDI – David Heffernan Sep 25 '12 at 21:30
  • @David, I see. I took MDI as a user interface, not as a MS' implementation. The problem is that MDI and MDI are sometimes badly distinguishable :-) Next time I'll better focus on context. – TLama Sep 25 '12 at 21:47

1 Answers1

14

This appears to be a known issue related to actions and the way they are updated in the application idle handler. The following QC report describes your scenario: http://qc.embarcadero.com/wc/qcmain.aspx?d=12706

The solution to your problem, according to the QC report, is to set the TApplication.ActionUpdateDelay property to a value greater than 0.

What I would love to know is why the presence of a maximized client form leads to the VCL's DoActionIdle being called in a busy loop. Presumably execution of an actions's OnUpdate handler leads to another queued message, and another idle cycles, and so on. I'd have thought dealing with that would be the best way to tackle this issue, but perhaps it's hard to achieve.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • Note that [QualityCentral has now been shut down](https://community.embarcadero.com/blogs/entry/quality-keeps-moving-forward), so you can't access `qc.embarcadero.com` links anymore. If you need access to old QC data, look at [QCScraper](http://www.uweraabe.de/Blog/2017/06/09/how-to-save-qualitycentral/). – Remy Lebeau Jun 09 '17 at 17:58