Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 使用CFDictionaryRef和ABMutableMultiValueRef的无法解释的泄漏_Objective C_Cocoa_Cocoa Touch - Fatal编程技术网

Objective c 使用CFDictionaryRef和ABMutableMultiValueRef的无法解释的泄漏

Objective c 使用CFDictionaryRef和ABMutableMultiValueRef的无法解释的泄漏,objective-c,cocoa,cocoa-touch,Objective C,Cocoa,Cocoa Touch,下面的代码创建了大量泄漏,我在释放使用Create或Copy创建的所有对象时不理解这些泄漏。我没有广泛使用CF对象,因此可能对保留周期有误解。如有任何帮助,请: ABMutableMultiValueRef webServices = ABRecordCopyValue(aRecord, kABPersonInstantMessageProperty); for (CFIndex i = 0; i < ABMultiValueGetCount(webServices); i++)

下面的代码创建了大量泄漏,我在释放使用Create或Copy创建的所有对象时不理解这些泄漏。我没有广泛使用CF对象,因此可能对保留周期有误解。如有任何帮助,请:

ABMutableMultiValueRef webServices = ABRecordCopyValue(aRecord, kABPersonInstantMessageProperty);

    for (CFIndex i = 0; i < ABMultiValueGetCount(webServices); i++) { 

        CFDictionaryRef webService = CFDictionaryCreateCopy(NULL, ABMultiValueCopyValueAtIndex(webServices, i));

        webServiceLabel = ABMultiValueCopyLabelAtIndex(webServices, i);

        webServiceProvider = CFDictionaryGetValue(webService, kABPersonInstantMessageServiceKey);
        webServiceUserName = CFDictionaryGetValue(webService, kABPersonInstantMessageUsernameKey);

        // Data to be saved at this point
        if (webService) CFRelease(webService);
        if (webServiceLabel) CFRelease(webServiceLabel);
    }

    if (webServices) CFRelease(webServices);
ABMutableMultiValueRef-webServices=ABRecordCopyValue(aRecord,kABPersonInstantMessageProperty);
对于(CFIndex i=0;i
我像这样运行模拟器

MallocStackLogging=1 /Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app/Contents/MacOS/iPhone\ Simulator
然后运行应用程序,然后运行appname

<>我把你的代码放在一个测试应用程序中,并没有真正看到很多事情发生,一些“泄漏”的形式在基础或可可代码中分配得很深。


你能用上面的代码运行你的应用程序并显示可以追踪到运行上面代码的方法的漏洞吗?

我像这样运行模拟器

MallocStackLogging=1 /Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app/Contents/MacOS/iPhone\ Simulator
然后运行应用程序,然后运行appname

<>我把你的代码放在一个测试应用程序中,并没有真正看到很多事情发生,一些“泄漏”的形式在基础或可可代码中分配得很深。

你能用上面的代码运行你的应用程序并显示可以追溯到运行上面代码的方法的漏洞吗?

这是你的问题:

CFDictionaryRef webService = CFDictionaryCreateCopy(NULL, ABMultiValueCopyValueAtIndex(webServices, i));
ab多值CopyValueAtIndex
创建一个从未分配给变量的对象。它需要被释放,但永远不会被释放。这是内存泄漏。

这是您的问题:

CFDictionaryRef webService = CFDictionaryCreateCopy(NULL, ABMultiValueCopyValueAtIndex(webServices, i));

ab多值CopyValueAtIndex
创建一个从未分配给变量的对象。它需要被释放,但永远不会被释放。这是内存泄漏。

您好,我使用指示泄漏不是从方法(直接)调用的工具运行泄漏。我只能假设必须有一种特殊的方法来发布通讯簿多值字典。ABMutableMultiValueRef是一个CFTypeRef,所以不需要它。我只是认为你看到的泄漏不是你必须担心的事情。嗨,我使用仪器运行泄漏,这表明泄漏不是从方法(直接)调用的。我只能假设必须有一种特殊的方法来发布通讯簿多值字典。ABMutableMultiValueRef是一个CFTypeRef,所以不需要它。我只是觉得你看到的泄密不是你应该担心的。