为什么 NSApplescriptexecuteAndReturnError: 似乎泄漏内存?

发布于 2024-11-19 18:40:18 字数 513 浏览 4 评论 0原文

我不确定,但是这样:

 -(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:

enter image description here

in Instruments memory leak tool. Am I doing something wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

萌吟 2024-11-26 18:40:18

这是一次性的事情,还是每次调用时都会发生?在第一种情况下,对于 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.

纵山崖 2024-11-26 18:40:18

考虑切换到 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文