Memory usage with ETS

Ulf Wiger ulf@REDACTED
Fri Aug 5 22:24:22 CEST 2005


Den 2005-08-05 19:16:53 skrev Peter-Henry Mander  
<erlang@REDACTED>:

> For example, I've rewritten the timer module so that I can specify timer
> periods with microsecond granularity to enable issuing messages at rates
> of, say 333 cps (the timer approximates the period to the nearest
> millisecond and will achieve 333 cps on average). I've used ETS to store
> the timer sequence since inserting into lists gets very costly as the
> number and frequency of the timers increases. I haven't run the timer
> for very long but I suspect the ETS table will grow monotonically. How
> can I reduce the memory footprint without resorting to table copying
> which will disrupt the timer?

Here's a suggestion: skip the timer module and use the
timer BIFs instead. Actually, even starting a regular process
per timer is much more efficient than using the timer module,
and the BIFs erlang:send_after/3 and erlang:start_timer/3
are *much* more efficient and scale very well.

/Uffe
-- 
Ulf Wiger



More information about the erlang-questions mailing list