Re: confused about allocating and releasing objects
Re: confused about allocating and releasing objects
- Subject: Re: confused about allocating and releasing objects
- From: Graham Cox <email@hidden>
- Date: Wed, 27 Aug 2008 21:22:31 +1000
On 27 Aug 2008, at 9:13 pm, Memo Akten wrote:
At the start of the plugin (in enableExecution) I use the code:
- (void) loadCardXMLData {
NSString *dataPath = @"/data.plist";
cardsLoadedData = [NSDictionary dictionaryWithContentsOfFile:
dataPath];
// cardsLoadedData = [[NSDictionary alloc] initWithContentsOfFile:
dataPath];
if(cardsLoadedData) {
NSLog(@"*** SUCCESSFULLY LOADED %@", dataPath);
} else {
NSLog(@"*** COULD NOT LOAD %@", dataPath);
}
}
If I use the convenience route (with no release in disableExecution)
I get a freeze (I need to force quit QC) as soon as I enable the
plugin. If I use the alloc route (and release in disableExecution)
everything works fine. Is this normal behaviour? or could it be QC
related?
Just thinking aloud, but I wonder if the plug-in is being executed
outside of the app's autorelease pool stack? The freeze could be
because autorelease is being called but there's no pool available. You
could try adding a pool to the top of the code to see if it stabilises
it, e.g. on the first line of the above:
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
If that turns out to be the case, you may need to move your code
elsewhere within the plugin (I'm not familiar with the plug-in system
in Cocoa so I'm not sure what you should be doing here) or else set up
a pool on entry.
hth,
Graham
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden