-[NSWorkspace frontmostApplication] has memory leaks

Originator:cocoastream
Number:rdar://10948537 Date Originated:29-Feb-2012 12:33 AM
Status:Open Resolved:
Product:Mac OS X Product Version:10.7.3
Classification:Serious Bug Reproducible:Always
 
Summary:

/* Gets the frontmost application, which is the application that will receive key events.  This is observable through KVO. */
- (NSRunningApplication *)frontmostApplication NS_AVAILABLE_MAC(10_7);

Unfortunately, this method generates memory leaks when you observe the frontmostApplication via KVO.

Steps to Reproduce:

1. Clone https://github.com/shpakovski/frontmostApplicationKVO
2. Open and build the project in Xcode
3. Profile the app using the Leaks instrument
4. To reproduce a memory leak, click the checkbox Observe several times

Expected Results:

No memory leaks.

Actual Results:

Memory leaks in NSRunningApplication class.

Regression:

NSWorkspace has support for NSWorkspaceDidActivateApplicationNotification that can be used to track a frontmost app. Anyway, KVO observing sounds more convenient.

Comments

It seems to be fixed

Tested on 10.8.3, no memory leaks.

By cocoastream at May 26, 2013, 8:36 a.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!