Re: Memory management question
Re: Memory management question
- Subject: Re: Memory management question
- From: Ondra Cada <email@hidden>
- Date: Wed, 24 Mar 2004 23:32:12 +0100
Alastair,
On Wednesday, Mar 24, 2004, at 23:10 Europe/Prague, Alastair Houghton
wrote:
Also as has been pointed-out before, if you do accidentally write such
code, you'll normally cause a crash, which makes it pretty easy to
debug
Well, also, as has been pointed-out before, if you do accidentally
write such code, there's a quite non-trivial probability you made a
ticking bomb which just *happens* not to crash now, but will with a new
framework/engine/library/bundle/haxie release... creating so one
*extremely* hard-to-find bitch problem.
Nevertheless, I take it you are well aware of this part of the argument
too, and am writing this message actually just for the benefit of other
readers (who are truly invited to check the archives, where all the
arguments of both sides are stated--many times over ;)--and judge for
themselves whether they generally prefer safety or efficiency).
At the very least (again for the benefit of other readers, of course)
it should be strongly pointed out that so far as one uses code with
plain getters (and *especially* if the setters are just releasing
/instead of autoreleasing/), one should be *very* careful with *any*
code of kind
id o=[foo getter];
// any code here (*)
// o used now
and wherever there is the slightest suspicion the (*) code may,
whatever indirectly or in future releases, cause the setter to be
called, one should always use the safe pattern
id o=[[[foo getter] retain] autorelease];
// any code here
// o used now
instead.
---
Ondra Hada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc
_______________________________________________
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.