stdlib Timer bug
Rudolph van Graan
rvg@REDACTED
Wed Oct 5 13:46:04 CEST 2005
Hi there,
{ok,TRef} = timer:apply_interval(2000,null,go,[]);
go() ->
TS = calendar:now_to_local_time(now()),
io:format("Tick ~p\n",[TS]).
This works as expected:
Tick {{2005,10,5},{13,39,8}}
Tick {{2005,10,5},{13,39,10}}
Tick {{2005,10,5},{13,39,12}}
Tick {{2005,10,5},{13,39,14}}
Tick {{2005,10,5},{13,39,16}}
Tick {{2005,10,5},{13,39,18}}
Tick {{2005,10,5},{13,39,20}}
Now I put the machine to sleep
and wait 20s
Now the timer tries to catch up with the system and posts events for
the time the machine was sleeping:
Tick {{2005,10,5},{13,39,39}}
Tick {{2005,10,5},{13,39,39}}
Tick {{2005,10,5},{13,39,39}}
Tick {{2005,10,5},{13,39,39}}
Tick {{2005,10,5},{13,39,39}}
Tick {{2005,10,5},{13,39,39}}
Tick {{2005,10,5},{13,39,39}}
Tick {{2005,10,5},{13,39,39}}
Tick {{2005,10,5},{13,39,39}}
And now it continues as per usual
Tick {{2005,10,5},{13,39,40}}
Tick {{2005,10,5},{13,39,42}}
Tick {{2005,10,5},{13,39,44}}
Tick {{2005,10,5},{13,39,46}}
Tick {{2005,10,5},{13,39,48}}
Tick {{2005,10,5},{13,39,50}}
My issue is that if a machine sleeps for 5 hours or more, we can get
millions of these events in the queue. Obviously, it is not an issue
on "always on" type systems and is only visible on my laptop.
However, I still think there should be a patch for timer to skip
ahead if it is too far behind and not to try and make things worse.
On my test system, this effect basically destroys my VM as each timer
message launches a new process which essentially kills the OS.
Suggestions?
Rudolph van Graan
More information about the erlang-questions
mailing list