| Article: |
Inside StYNCies | |
| Subject: | leaks? | |
| Date: | 2005-03-14 08:41:27 | |
| From: | hieper | |
|
You seem to be leaking instances of IPodUtils and NSFileManager (and NSStatusItem) in your AppController. (any reason why you don't use [NSFileManager defaultManager]?
|
||
Showing messages 1 through 4 of 4.
-
leaks?
2005-03-14 09:17:30 Matthew Russell |
[View]
-
leaks?
2005-03-17 01:47:45 hieper [View]
[prefsController dealloc] ??? -
leaks?
2005-03-17 07:04:35 Matthew Russell |
[View]
As you mentioned, breaking up is hard to do. Given the context of what's going on, you don't have a prefsController. Axe that line. -
leaks?
2005-03-14 13:10:58 hieper [View]
I'm still not happy with this version of dealloc, the other one was better, really. I guess Neil Sedaka was right: 'breaking up is hard to do" ;-)
It would be nice if you could correct the main article text with a correct version.
About NSFileManager, I don't now why, but somehow the shared defaultManager is stuck in my mind as being 'preferred'. Maybe it is because the documentation says: You invoke all NSFileManager instance methods with this object as the receiver, whichs sound a bit like 'you must...'. It doesn't give a real reason though.
greetings,
patrick



Thanks for pointing those things out. In the process of taking a full project and breaking up into two pieces for each of the articles, I neglected to remove the mRTFDData references. Those should just be commented out for the moment; they'll be introduced in the next piece as part of a class that's used to read/write from the StickiesDatabase file.
There's no particular reason why I didn't use [NSFileManager defaultManager]. That way is probably more preferred as you seem to imply, however, so there's no reason not to go with it.
As for the dealloc issues involving memory, the dealloc I have here on my machine didn't turn out to be the same one that was published. Amazingly, what is in the article is the first half of AppController's dealloc method joined with the last half of a dealloc method from a class not introduced yet. Not quire sure how that happened; must have been a cut/paste error. Try this one instead:
/*dealloc for AppController */
- (void)dealloc
{
NSNotificationCenter* nc;
nc = [NSNotificationCenter defaultCenter];
[nc removeObserver:self];
[statusItem release];
[prefsController dealloc];
[podUtil dealloc];
[userDefaults dealloc];
[fileManager dealloc];
[super dealloc];
}
As for calling or not calling init in the interface--I know they're inherited from NSObject. It's just my preference to make the interface and implementations match, and something I think of as a good practice. I personally find this to be a good indicator to use for when something's being overridden. Feel free to differ if you have different preferences.
Thanks again for helping to clear those things up.
M.