destroy timer - automatic ?

Are timers destroyed automatically when their iterations are finished ?

timer.performWithDelay(2000, something, 2)

So the above will run twice and then it is destroyed / garbage collected ?
Or do I have to nil it ?

I see that if it was
timer.performWithDelay(2000, something, 0)
then I would run cancel on it and then nil it, yes ? [import]uid: 186251 topic_id: 33286 reply_id: 333286[/import]

@sam3dus, it is my understanding that the already fired timer would be eventually garbage collected (and if it’s not the case, I’d like to know.)

When I do have timers that may need to be cancelled, I always give it a handle, like so:

myTimer = timer.performWithDelay(2000, something, 0)  
  
-- when I want to cancel it  
timer.cancel( myTimer )  
myTimer = nil   
-- I guess the above is nilling out the reference to the timer attached to the   
-- variable/handle called myTimer, and the actual timer itself is eventually   
-- garbage collected after it is cancelled.  

Naomi [import]uid: 67217 topic_id: 33286 reply_id: 132250[/import]

@Naomi - thanks, makes sense but wanted to ask and make sure.

>and if it’s not the case, I’d like to know

you, me and many others [import]uid: 186251 topic_id: 33286 reply_id: 132257[/import]

@sam3dus, it is my understanding that the already fired timer would be eventually garbage collected (and if it’s not the case, I’d like to know.)

When I do have timers that may need to be cancelled, I always give it a handle, like so:

myTimer = timer.performWithDelay(2000, something, 0)  
  
-- when I want to cancel it  
timer.cancel( myTimer )  
myTimer = nil   
-- I guess the above is nilling out the reference to the timer attached to the   
-- variable/handle called myTimer, and the actual timer itself is eventually   
-- garbage collected after it is cancelled.  

Naomi [import]uid: 67217 topic_id: 33286 reply_id: 132250[/import]

@Naomi - thanks, makes sense but wanted to ask and make sure.

>and if it’s not the case, I’d like to know

you, me and many others [import]uid: 186251 topic_id: 33286 reply_id: 132257[/import]