Note that there are some explanatory texts on larger screens.

plurals
  1. POSecItemCopyMatching still leak on osx under ARC
    primarykey
    data
    text
    <p>i found memory leak on SecItemCopyMatching. After investigate on SF i was found solution:</p> <pre><code>__block NSString *certificateName = nil; SecKeychainRef keychain; SecKeychainCopyDefault(&amp;keychain); NSMutableDictionary *attributeQuery = [NSMutableDictionary dictionary]; [attributeQuery setObject: (id) kSecClassIdentity forKey:(__bridge_transfer id) kSecClass]; [attributeQuery setObject: (id) kCFBooleanTrue forKey:(__bridge_transfer id) kSecReturnRef]; [attributeQuery setObject: (id) kSecMatchLimitAll forKey:(__bridge_transfer id) kSecMatchLimit]; CFTypeRef attrResult = NULL; OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef) attributeQuery,(CFTypeRef *) &amp;attrResult);&lt;------- here is a leak according Instruments if (status != errSecItemNotFound) { NSArray *attributeResult = (__bridge_transfer NSArray *)attrResult; [attributeResult enumerateObjectsUsingBlock:^(id identityFromArray, NSUInteger idx, BOOL *stop) { OSStatus status; SecCertificateRef cert = NULL; status = SecIdentityCopyCertificate((__bridge SecIdentityRef)identityFromArray, &amp;cert); if (!status) { </code></pre> <p>or another solution:</p> <pre><code>NSMutableDictionary *attributeQuery = [NSMutableDictionary dictionary]; [attributeQuery setObject: (id) kSecClassIdentity forKey:(__bridge_transfer id) kSecClass]; [attributeQuery setObject: (id) kCFBooleanTrue forKey:(__bridge_transfer id) kSecReturnRef]; [attributeQuery setObject: (id) kSecMatchLimitAll forKey:(__bridge_transfer id) kSecMatchLimit]; CFTypeRef attrResult = NULL; CFDictionaryRef cfquery = (__bridge_retained CFDictionaryRef)attributeQuery; OSStatus status = SecItemCopyMatching(cfquery,(CFTypeRef *) &amp;attrResult);&lt;------- here is a leak according Instruments if (status != errSecItemNotFound) { NSArray *attributeResult = (__bridge_transfer NSArray *)attrResult; [attributeResult enumerateObjectsUsingBlock:^(id identityFromArray, NSUInteger idx, BOOL *stop) { OSStatus status; SecCertificateRef cert = NULL; status = SecIdentityCopyCertificate((__bridge SecIdentityRef)identityFromArray, &amp;cert); if (!status) { char *nameBuf = NULL; CFStringRef nameRef = NULL; OSStatus statusNew = SecCertificateInferLabel(cert, &amp;nameRef); ..... CFRelease(cfquery) </code></pre> <p>But both of them still do leak for me.</p> <p>Any another ideas</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload