How Can We Help?
< All Topics

Optimizing Macro Express Pro CPU Utilization

In certain circumstances, Macro Express may use too many CPU cycles. This can occur if you are using a slower computer. This may also occur when a single computer is being used by many users, for example when using Citrix or Windows Terminal Services.

Most users with a reasonably fast computer will never notice a problem with Macro Express’s CPU utilization.

The way the macros are written and which macro activations are used can affect how much of the CPU Macro Express uses. This article describes techniques to minimize the CPU load when Macro Express is running on your computer. Also keep in mind that if the program your macro is automating is running slowly, then Macro Express’s macro will run slowly.

Delay Commands

There are two types of delay commands that can be used inside a macro. The ‘Delay: Seconds’ and ‘Delay: Milliseconds’ commands run code that loops waiting for the time to expire. This loop can use a lot of the CPU.

The ‘Delay without ability to halt’ and ‘Wait for Time to Elapse’ commands tell Windows to put Macro Express Pro to ‘sleep’ for the specified amount of time. This type of delay uses very few CPU cycles.

Of course there is a trade-off. Because the thread running the macro is ‘sleeping’ when you use the ‘Delay: without ability to halt’ or ‘Wait for Time to Elapse’ commands, you cannot halt the macro by clicking on the Macro Express Pro icon or by pressing the ‘Abort Macro HotKey’.

Control Activated and Window Activated macros

The type of activation used by your macros can affect the CPU utilization. If you have Window Activated and/or Control Activated macros then Macro Express Pro has to constantly (every 1/4 second) monitor the Windows messages to see if one of the macros should be activated. This is CPU intensive. Avoiding these macro activations may help performance.

Scheduled Macro Timer Interval

By default, every 10 seconds Macro Express Pro checks the list of scheduled macros to see if it is time for any of them to run. In the preferences you can change the Timer Interval to check more frequently or less frequently. Setting the Timer Interval to check more frequently will cause Macro Express Pro to use more CPU cycles.

Restart Macro Express Pro periodically

Some customers have experienced what they describe as a ‘memory leak’ with Macro Express Pro. There are two definitions of a ‘memory leak’. The first and most common description is that a program does not free up all memory when the program closes. The second, and less common, description is that a program gradually uses more memory the longer it runs.

Macro Express Pro does a good job of freeing memory when it terminates. (Actually, Windows manages memory. It is more accurate to say that Windows correctly frees memory when Macro Express Pro is closed.) However, in some environments, the longer Macro Express Pro runs, the more memory is used by Macro Express Pro. In our lab tests we have found that when some macro commands run there are very small amounts of memory (16 bytes) that are not freed. The commands used and the frequency at which they run affect how much memory is lost.

Macro Express Pro goes through the motions of freeing up memory at the correct times. The problem seems to be coming from Windows itself.

The longer Macro Express Pro runs, the more memory is ‘lost’. As memory is ‘lost’, your computer slows down. People who reboot their systems at least daily do not notice any memory leaks. Those that notice a problem with memory loss are the ones that leave Macro Express Pro running 24 x 7.

Our recommendation is to restart Macro Express Pro every 24 to 48 hours or so. Depending on your environment, you may be able to restart Macro Express Pro only once a week. You may use the ‘Restart Macro Express’ command to restart Macro Express Pro. You could put this command in a scheduled macro that runs between 1:00 AM and 2:00 AM and only runs when the computer is idle (see the ‘Time Out’ type of scheduled macro). You could keep track of whether the macro has run ‘today’ by storing the date somewhere and comparing it with today’s date. Restarting Macro Express Pro this way takes only a brief moment.

Wait for commands

When a macro is using one of the ‘Wait for’ commands, the macro stops and waits for the specific event. As it is waiting, Macro Express Pro is put to ‘sleep’. However, excessive use of the ‘Wait for’ commands may use a lot of CPU cycles.

Repeat commands

As is the case in any programming language, a repeat loop can cause a huge load on the CPU. You can help reduce the CPU load by being careful about how you use repeat loops within your macros.

– Applies to: Macro Express Pro