为什么 NSApplescriptexecuteAndReturnError: 似乎泄漏内存?
我不确定,但是这样:
-(void)quitFinder {
NSAppleScript *restartFinder = [[NSAppleScript alloc] initWithSource:@"tell application \"Finder\" to quit"];
[restartFinder executeAndReturnError:nil];
[restartFinder release];
}
当这样调用时:
[self performSelectorOnMainThread:@selector(quitFinder) withObject:nil waitUntilDone:YES];
会产生这样的:
在 Instruments 内存泄漏工具中。我做错了什么吗?
I'm not sure, but this:
-(void)quitFinder {
NSAppleScript *restartFinder = [[NSAppleScript alloc] initWithSource:@"tell application \"Finder\" to quit"];
[restartFinder executeAndReturnError:nil];
[restartFinder release];
}
when called like this:
[self performSelectorOnMainThread:@selector(quitFinder) withObject:nil waitUntilDone:YES];
yields this:
in Instruments memory leak tool. Am I doing something wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一次性的事情,还是每次调用时都会发生?在第一种情况下,对于 OSA/AppleScript 设置的某些永久状态来说,这可能是误报。
Is this a one-time thing, or does it happen every time you call it? In the first case, it’s likely to be a false positive for some permanent state set up by OSA/AppleScript.
考虑切换到 OSAKit。该 API 与 NSAppleScript 非常相似,但更广泛,因此这应该接近无痛。
如果 OSAKit 没有泄漏,那么问题很可能出在 NSAppleScript 中,我建议提交错误 附上您的 Instruments 跟踪文档。
Consider switching to OSAKit. The API is very similar to NSAppleScript, but broader, so this should be close to painless.
If OSAKit doesn't leak, then the problem may very well be in NSAppleScript, and I'd recommend filing a bug with your Instruments trace document attached.