Memory leak in SwiftUI when pressing keys (detected by instruments)

I've discovered what appears to be a system-level memory leak when pressing any key in Swift UI projects. This issue occurs even in a completely empty SwiftUI project with no custom code or event handlers.

When monitoring with Instruments' Leaks tool, I observe multiple memory leaks each time any key is pressed. These leaks consist primarily of:

NSExtraData objects (240 bytes each) NSMenuItem objects (112 bytes each) Other AppKit and Foundation objects

Has anyone else encountered this issue? How can I fix this behavior? While the leaks are small (about 5-6KB per keypress), they could potentially accumulate in applications where keyboard input is frequent.

This may be a bug which has been resolved in recent macOS or Xcode versions. If you're seeing this with old macOS or Xcode, consider updating to the most current versions.

If it's still reproducing with current releases, consider filing a bug report using Feedback Assistant. Please include the macOS and Xcode version you're using and detailed steps to reproduce, and ideally a small Xcode project for which this reproduces.

Memory leak in SwiftUI when pressing keys (detected by instruments)
 
 
Q