Re: release not done right away
Re: release not done right away
- Subject: Re: release not done right away
- From: j o a r <email@hidden>
- Date: Wed, 21 Apr 2004 14:05:49 +0200
On 2004-04-21, at 13.28, Nicolas Berloquin wrote:
>
I'm using one timer for each peer that I need to prune. what happens
>
is this :
>
(all in the main runloop btw) :
>
at some point the NBPeer sees that the connexion is closed/dead. From
>
the
>
chain of events that leads to this info, It can't [self release]
>
itself, so a timer is setup
>
to kill it after 2 seconds (from the selector of another object,
>
actually the object
>
that holds the array of NBPeers), like "prune me, I'm dead anyway".
Do you really need to delay things like this? Think carefully about it,
because you'll avoid a lot of problems in the long run if you can do
things synchronously.
>
You see, this part of the app is completely timer driven. No event
>
loop (why should I need one ?
>
(it will become necessary only if there is no other way to manage the
>
autoreleases)).
>
Using timers this way makes it very simple for me to handle everything.
Timers are run loop sources, and will start a little event loop of
their own when they fire.
>
> Why is it strange? This is a valid optimization- if the app doesn't
>
> need to do anything, it doesn't. Why are you using more than one
>
> NSTimer?
>
>
this is strange (in my opinion), because RAM isn't infinite, and
>
neither is swap space. what if all this ends up taking gigabytes of
>
memory ? This would make the user's mac crawl when simple autorelease
>
GC would have prevented it.
The problem is that you keep adding autoreleased objects to an
environment where they aren't taken care of. This is not a general
problem in Cocoa, it's a problem with your design that you need to fix.
j o a r
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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.