Re: monitoring retainCount
Re: monitoring retainCount
- Subject: Re: monitoring retainCount
- From: Drew Thaler <email@hidden>
- Date: Thu, 27 May 2004 00:48:04 -0400
On May 27, 2004, at 12:04 AM, Stefan Fisk wrote:
well, my motivation is suspect =)
the idea of caching the objects just struck me as sane, if it was
doable, which it doesn't seem to be without hacks like
poseAs:[NSObject class], and i'm very skeptical to stuff like that, to
say the least..
That's almost certainly premature optimization. :-) Especially now that
computers run billions of operations per second, programmers should
always focus on algorithmic optimization first. If you find that you're
deallocing and reallocing new objects all the time, fix your code!
It's like the old doctor/patient joke... Novice: My program is slow
because I'm allocating and disposing thousands of objects in a tight
loop! Guru: So don't do that.
There are of course ways you can re-use instances of your own classes,
particularly if you know they're immutable. In particular, there are
tricks like using placeholder objects and pools. Rather than wasting
time talking about it myself, here are two somewhat decent articles on
that subject with sample code:
http://www.mulle-kybernetik.com/artikel/Optimization/opti-2.html
http://www.mulle-kybernetik.com/artikel/Optimization/opti-5.html
Again, though, unless you are really having problems this is definitely
premature optimization. The far, far better solution to improving alloc
and dealloc speed is to fix your algorithm so that you're not doing it
so often. :-)
drew
--
Drew Thaler
Recording Artist
Email/AIM: email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.