gpt4 book ai didi

cocoa - 脚本桥 : Are These Leaks Mine or Scripting Bridge?

转载 作者:行者123 更新时间:2023-12-03 17:23:34 24 4
gpt4 key购买 nike

我将我的应用程序从使用垃圾收集转换为 ARC。该应用程序使用 ScriptingBridge 框架。出于好奇,我使用 Instruments“Leaks”模板运行它,发现有泄漏。 AEDESImpl 对象不是由我的代码直接创建的,它们似乎是由 Scripting Bridge 创建的。我说得对吗?

如果这些泄漏来自 ScriptingBridge,这是否正常,我只能忍受它?

谢谢。

这是一个仪器图像,显示“循环和根”->“泄漏循环”:

image

我输入了相关部分。
_NSCFArray

    +40 ( no ivar ]: AEDescImpl  
      +56 [ no ivar ]: AEDescImpl  
      +64 [ no ivar ]: AEDescImpl  
      +72 [ no ivar ]: AEDescImpl  
      +80 [ no ivar ]: AEDescImpl  
      +88 [ no ivar ]: AEDescImpl  
      +96 [ no ivar ]: AEDescImpl  


Peter's comment about including the method findOpenTuner in its entirety spurred me to create a "mini" project. The method in question was large and had many methods calls so I reduced the method down to its essence. I added a for loop to call the method 24 times as it ran so fast Instruments did not have any chance to see anything.

Out of curiosity, I commented out the for loop on EyeTVPlayer_window and ran Instruments on that and found no leaks or cycles. With this for loop uncommented as seen below, the leaks are present. It seems to me that either my coding is not correct or Scripting Bridge is leaking.

The "mini" project's implementation file.

#import "AppDelegate.h"
#import "EyeTV.h"

@implementation AppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSUInteger i;
for (i=0; i<25; i++) {
NSLog(@"before i=%li", i);
[self findOpenTuner];
NSLog(@"after i=%li", i);
}
}

- (void)findOpenTuner;
{
EyeTVApplication *eyeTVApp;

eyeTVApp = [SBApplication applicationWithBundleIdentifier:@"com.elgato.eyetv"]; // 08-04-2011 needed to do mute below in method call filterPlayVolumeMute

SBElementArray *eyeWindows = [eyeTVApp player_windows]; // are EyeTVWindow

BOOL openTunerFound = FALSE; // 07-21-2010
int j=0;
for (EyeTVPlayer_window *eyeWin in eyeWindows) // 12-07-2012 #1
{
if ([[eyeWin programInfo] count] == 0) {
} else {
// this is the tuner we want
openTunerFound = FALSE; // 07-21-2010
[eyeWin select]; // 07-21-2010 // moves "focus" to window, places it at index 0
break; // 07-21-2010 // got the tuner, leave loop
}
j++;
}
}

@end

“迷你”项目的仪器屏幕截图。

enter image description here enter image description here

最佳答案

ScriptingBridge 也存在同样的问题。我最终用自动释放池封装了负责的代码。

@autoreleasepool {
// Leaking code
}

这消除了最大的泄漏,现在它只在我的应用程序上泄漏几个字节。

关于cocoa - 脚本桥 : Are These Leaks Mine or Scripting Bridge?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13925014/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com