Skip to content

Mouser v3.7.4

Latest

Choose a tag to compare

@github-actions github-actions released this 28 Nov 14:16
7bd6737

Mouser v3.7.4

A macOS memory fix, for the leak v3.7.1 did not catch. If Mouser kept growing into the gigabytes on your Mac while you scrolled and moved the mouse (#314, and the comments on #265), this release is for you. Windows and Linux behave as before, apart from a new line in the log.

🧠 The leak

Every scroll tick and pointer movement that Mouser passes through to your apps stayed in memory for the rest of the session.

The cause is not one of Mouser's own objects. The PyObjC bridge that delivers events to Mouser's event tap (pyobjc-framework-Quartz, up to and including 13.0) converts the event Mouser returns and then never releases it, so each event's CGEvent, its CGSEventAppendix and three HIDEvent attachments lived until you quit. Remapped button clicks are swallowed instead of returned, which is why clicks never showed the problem and scrolling did: the "scroll leaks, clicks don't" pattern from #233. Autorelease pools, the fix in v3.7.1, cannot reclaim it, because the stray reference is held on the Python side.

  • Fix (#337): the tap now hands PyObjC one long-lived wrapper instead of each event, so at most one event is ever retained. It is correct on every PyObjC version.
  • Fixed upstream too: PyObjC 13.1 (2026-11-24) adds the missing release, and the official macOS builds (Apple Silicon and Intel) of this release bundle it.

Evidence. @raduraducu's heap -s captures on a signed build showed 34,708 CGEvent and 104,058 HIDEvent objects after four hours without the change, against 7 and 6 with it, and a flat footprint. @Han1enG independently pushed 100,000 events through the real PyObjC trampoline: 29 → 67 MiB without the change, 29 → 30 MiB with it.

Note

We do not yet have a 24-hour real-world run of this exact build. If you can leave Mouser running for a day with normal scrolling, please attach the [Memory] lines from mouser.log (below) to #314.

🔍 Far fewer foreground-app lookups (macOS)

Mouser used to ask NSWorkspace for the frontmost app three times a second, about 288,000 calls a day. It now waits for the system's "application activated" notification and looks the app up only when it changes, falling back to polling if the notification cannot be registered (#333, thanks @ZMel). This targets the slow creep noted as a known residual in v3.7.1.

📈 Memory in the log

  • mouser.log now carries a [Memory] footprint=… rss=… py_heap_blocks=… threads=… uptime=… line at startup and every 10 minutes, on every platform. If footprint climbs while py_heap_blocks stays flat, the growth is native memory rather than Python objects. On macOS the log also records which PyObjC version is in use.
  • tools/macos_memory_report.py (#341, thanks @Han1enG) snapshots footprint and heap class counts of a running Mouser, so two samples can be compared.

ℹ️ Still open

The several hundred MB some of you see right after launch (#265) is largely the Qt runtime rather than a leak: the proposed split of the macOS daemon from the on-demand UI (#243) measured about 280 MB falling to about 48 MB. That change is still a draft.

🙏 Thanks

To @raduraducu for finding the cause and fixing it, to @ZMel and @Han1enG for the polling change and the measurement tooling, and to @jimmylzt188, @kkkpc, @hongruiji, @kilgad2 and @fosron for reporting that something was still wrong after v3.7.1.

Full changelog: v3.7.3...v3.7.4