Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a reason why CPU usage will jump when debugging in Word VBA?

I noticed that even when I "step into" a project, and nothing is actually being calculated except waiting for me to step to the next statement, the CPU goes up about 25-30% and stays there, across all 4 cores on a Core-i5 2400.

I can verify in Task Manager that WINWORD.EXE is the culprit. Memory use is consistent and expected. CPU usage up almost 30%, and it immediately drops off if I stop debugging.

This is in Office 2007.

share|improve this question
1  
Just because your VBA script is paused does not mean its runtime and debugger are not doing anything. my guess is your program thread is spinning while it waits for your next F10. –  Frank Thomas Sep 18 '13 at 16:19
    
Would this show as an additional thread under WINWORD.EXE? The number of threads remains constant if running the macro, debugging, or if the macro is stopped and I'm just coding. –  Aaron Thomas Sep 18 '13 at 16:24
    
the metric you will likely notice is "Context Switches". when a thread is locked, it will spin for a cycle or two, and then send a pulse to indicate that its going to sleep for a few, and other threads may have CPU time. every time a thread yields execution, a Context Switch occurs in the yielding thread. –  Frank Thomas Sep 18 '13 at 16:28

1 Answer 1

up vote 0 down vote accepted

Debugging requires tracking all related objects and variables in addition to actually using them as they would in non-debug mode.

This tracking is still happening even while sitting waiting for you to hit "Next step" or alike.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.