High Memory Usage During Repetitive Keystrokes

Hi,

I have 'Keyboard Maestro Engine' process uses a lot of memory when sending "Type a Keystroke" multiple times.
As a test, I create a macro loop that sends the letter "K" (no delays). The engine process' memory usage increases 1MB every couple of seconds.
After extensive testing, I have found it only uses that memory when typing a keystroke and not when sending a mouse button click (mouse button 3,4,5, etc).

To see what would happen, I left the "K" macro run overnight. In the morning, my Mac's UI was super laggy and slow, memory usage was multiple gigabytes. I manage to force quit the engine and the Mac speeds back up to normal.

The next night I set up the same macro, but this time it sends the Mouse Button 4 instead of "K". I actually use "BetterTouchTool" to convert mouse buttons coming from Keyboard Maestro into "K". Basically the receiving app still sees "K" being entered, but KM is only sending Mouse Button Clicks.... In the morning the UI was perfect and the engine's memory usage was very low (idle usage).

Would this be a bug or a symptom of how KM operates?
It's just interesting how memory usage doesn't increase when sending mouse buttons, but it does when sending actual keys.

Thanks,
Lock

I had a look at this, and I can see what you mean in terms of the usage increasing.

However I looked at it with the developer memory leak tool, and it doesn't show any leaks happening, or indeed any increase in the memory usage in the Keyboard Maestro Engine. I looked closer at the Activity Monitor metrics, and if you open up Keyboard Maestro Engine in Activity Monitor and look at the memory, what is increasing is not the Private Memory (ie, memory that is solely for Keyboard Maestro Engine), but the Shared Memory Size.

I also noted that even after quitting Keyboard Maestro Engine, I was getting laggy typing and missed characters until I quit the application that I had been auto-typing in.

I'm not sure why the difference with using mouse clicks, maybe BTT uses a different API for posting events that doesn't suffer the issue.

I don't have any particular suggestions for this I'm afraid.