Created
February 11, 2014 13:42
-
-
Save rnapier/8935020 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example for http://stackoverflow.com/questions/21699184/resource-leak-or-not-mac-os-x | |
#import <CoreServices/CoreServices.h> | |
#import <SystemConfiguration/SCDynamicStore.h> | |
#import <SystemConfiguration/SCDynamicStoreCopySpecific.h> | |
#include <iostream> | |
#include <thread> | |
void Execute() | |
{ | |
CSIdentityAuthorityRef identityAuthority = CSGetLocalIdentityAuthority(); | |
if (!identityAuthority) | |
{ | |
std::cout << "Failed to get identity authority." << std::endl; | |
return; | |
} | |
CSIdentityQueryRef usersQuery(CSIdentityQueryCreate(nil, kCSIdentityClassUser, identityAuthority)); | |
if (!usersQuery) | |
{ | |
std::cout << "Failed to create query." << std::endl; | |
return; | |
} | |
///////////////////////////////////////////////// | |
// Without CSIdentityQueryExecute(usersQuery, 0, nil) - everething is ok. | |
///////////////////////////////////////////////// | |
if (!CSIdentityQueryExecute(usersQuery, 0, nil)) | |
{ | |
std::cout << "Failed to execute query." << std::endl; | |
return; | |
} | |
CFRelease(usersQuery); | |
} | |
int main(int argc, const char * argv[]) | |
{ | |
//for (int i = 0; i < 1000; ++i) | |
for (int i = 0; i < 5; ++i) | |
{ | |
std::cout << "Iteration # " << i << std::endl; | |
for (int j = 0; j < 1000; ++j) | |
{ | |
Execute(); | |
} | |
std::this_thread::sleep_for(std::chrono::seconds(1)); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment