Re: self release
Re: self release
- Subject: Re: self release
- From: Danny Swarzman <email@hidden>
- Date: Mon, 12 May 2003 12:53:28 -0700
I disagree with this! The best way to handle this is a Wolfgang first
stated. Of course there should be comments in the right places.
A factory method to create the object have a comment saying that these
objects are released in the suicide method.
There are two issues involved.
One is that threads should release their resources when they die, not at
some ambiguous time in the future. This is normal practice for very good
reasons.
Second is that the proverb "what you retain/alloc you must release" is bad
English usage. The "you" may be a method, several methods, an object, a
class - everyone understands this differently.
The proverb I propose is "avoid antropomorphism". If you are reading this,
I assume you are human being. For the present purpose, I consider myself to
be one.
The proverb for memory usage is "make sure that the count is zero when the
program is done".
Of course it is best write code so that the person reading it sees that
things are undone in the same part of the source code that they are done.
-Danny Swarzman
At 11:46 -0700 5/12/03, Wolfgang Ante wrote:
>
> Yes, that is definitely a bad idea, since it violates basic memory
>
> management principles. What you retain / alloc you must release!
>
>
Yes, good point!
>
>
So I think the best approach is your...
>
>
[[MyWorkingBee workingBeeWithWorkDesc:info] runInBackground];
>
>
...which is of course autoreleased and then in 'runInBackground' I
>
[self retain] and when finished I just [self release].
>
>
This way I do not break "what you retain/alloc you must release" and I
>
still get my suicidal object. ;-)
>
>
Thank you John and David for your help!
>
>
Bye, Wolfgang :-)
>
_______________________________________________
>
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.
_______________________________________________
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.