我想知道是否有人建议使用 runningApplications 的替代方法,因为类似以下内容似乎正在泄漏内存:
https://openradar.appspot.com/24067155 https://github.com/bradjasper/NSRunningApplicationMemoryLeaks
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
[NSTimer scheduledTimerWithTimeInterval:10.0 target:self selector:@selector(checkApps:) userInfo:nil repeats:YES];
}
- (void) checkApps : (id) sender {
@autoreleasepool {
NSArray *appsArray = [[NSWorkspace sharedWorkspace] runningApplications];
for (NSRunningApplication *a in appsArray) {
NSLog(@"%@", [a localizedName]);
}
}
}
等到 Apple 提供解决方案是唯一的选择吗?我在沙盒环境中工作,因此一些基于 NSTask 的替代方案可能不起作用。提前感谢您的任何想法。