After debugging it in more detail i found the code but doesn't know what is wrong here:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); NSString *applicationSupportDirectory = [paths objectAtIndex:0]; const std::string returnString([applicationSupportDirectory UTF8String]); // Cleanup the NSArray and the NSString [paths release]; [applicationSupportDirectory release]; return returnString;
After I changed it to the following everthing is working fine:
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); NSString *applicationSupportDirectory = [paths objectAtIndex:0]; const std::string returnString([applicationSupportDirectory UTF8String]); // Cleanup the NSArray and the NSString [pool release]; return returnString;
So, is the manual release wrong and is the memory being freed in the second example?
Best Regards
NoRulez wrote:
After debugging it in more detail i found the code but doesn't know what is wrong here:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); NSString *applicationSupportDirectory = [paths objectAtIndex:0]; const std::string returnString([applicationSupportDirectory UTF8String]); // Cleanup the NSArray and the NSString [paths release]; [applicationSupportDirectory release];
[applicationSupportDirectory release] is definitely wrong as it is just pointing to an item in the paths array. Doing a quick Google search for NSSearchPathForDirectoriesInDomains it seems you don't need to free up paths either (although some people claim it leaks memory).
So I don't think you need to release either, though I am not an objective C expert. If this is the case then using the NSAutoReleasePool will have no effect.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
