gpt4 book ai didi

ios - Ran分析器: Potential Memory Leak

转载 作者:行者123 更新时间:2023-11-29 03:36:20 25 4
gpt4 key购买 nike

enter image description here

嗨,

我运行了 XCode 分析器 - 它告诉我以下两者都是潜在的内存泄漏。我不知道为什么。我像这样声明了 midiDevices

@property (assign, nonatomic) NSMutableArray* midiDevices;

这是 openMidiIn 的代码

-(void)openMidiIn {
int k, endpoints;

CFStringRef name = NULL, cname = NULL, pname = NULL;
CFStringEncoding defaultEncoding = CFStringGetSystemEncoding();
MIDIPortRef mport = NULL;
MIDIEndpointRef endpoint;
OSStatus ret;

/* MIDI client */
cname = CFStringCreateWithCString(NULL, "my client", defaultEncoding);
ret = MIDIClientCreate(cname, NULL, NULL, &mclient);
if(!ret){
/* MIDI output port */
pname = CFStringCreateWithCString(NULL, "outport", defaultEncoding);
ret = MIDIInputPortCreate(mclient, pname, MidiWidgetsManagerReadProc, self, &mport);
if(!ret){
/* sources, we connect to all available input sources */
endpoints = MIDIGetNumberOfSources();
//NSLog(@"midi srcs %d\n", endpoints);
for(k=0; k < endpoints; k++){
endpoint = MIDIGetSource(k);
void *srcRefCon = endpoint;
MIDIPortConnectSource(mport, endpoint, srcRefCon);

}
}
}
if(name) CFRelease(name);
if(pname) CFRelease(pname);
if(cname) CFRelease(cname);

}

感谢您的帮助。


分析仪信息这是有关进行一些更改的错误的更多信息。

enter image description here

最佳答案

假设您使用 ARC,该对象实际上将立即被释放和释放。为什么它说你有内存泄漏令人困惑,但你将有一个死引用。使用strong,而不是分配

关于ios - Ran分析器: Potential Memory Leak,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19132167/

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