[erlang-questions] The timer server: bug or feature?

Serge Aleynikov saleyn@REDACTED
Thu Apr 16 03:23:40 CEST 2009


This seems rather odd indeed. I suggest you take a look at

ets:tab2list(timer_tab) -> [{{NextUSecSinceEpoch, Ref}, Timer, MFA}]
	Timer = timeout | {repeat, Interval, Pid}

and

ets:tab2list(interval_tab) -> [{Ref, {repeat, Interval, Pid}, MFA}]

and see if the Pids referenced in timer_tab are your gen_servers'.

Also you might want to set up a trace on timer:pid_delete/1 just to see 
if the pids are cleared indeed.

Serge

Scott Lystig Fritchie wrote:
> Hi, all.  I've got an app that uses the timer module liberally,
> specifically timer:send_interval/2.  I also have some regression tests
> that starts hundreds of gen_server and gen_fsm processes that use
> timer:send_interval/2 (usually with a period of 1 second) and are
> stopped a few seconds later ...  both nicely shutdown and
> not-very-nicely stopped by exit(Pid, kill).
> 
> After the regression tests finish and all test processes are dead, I
> find that the timer_server process is consuming about 45% of one of my
> CPU cores.  The undocumented timer:get_status/1 function says:
> 
>     (foo_dev@REDACTED)6> application:stop(foo).
>     ok
>     (foo_dev@REDACTED)7> timer:get_status().
>     {{timer_tab,1096},{timer_interval_tab,184}}
> 
> (This is Erlang/OTP R12B-5, on a Linux platform, if that matters.)
> 
> So it seems like there are hundreds of items that are orphaned in the
> timer server's private state.  Is this a bug or feature?  The OTP docs
> say that the caller of send_interval/2 will be link()'ed, which I assume
> means that cleanup should be automatic....
> 
> -Scott
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
> 




More information about the erlang-questions mailing list