Memory usage with ETS

Peter-Henry Mander erlang@REDACTED
Fri Aug 5 19:16:53 CEST 2005

Hi Gurus,

I've carried out a little experiment. The program I've written
originally used several ETS tables throughout it's processing lifetime,
and memory consumption grew gradually as it progressed. I have found
that periodically copying all the records over to a new table, deleting
the original table then calling erlang:garbage_collect/0 has helped to
stabilise memory consumption.

Is this a suitable method? Are there any drawbacks or gotchas I should
be wary of?

The program performance is dominated by disk access since it processes
call data records, so I doubt that copying a few tables with
approximately 32,000 records each will have a huge impact. However will
this method cause performance issues on other systems?

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?


"The Tao of Programming
 flows far away 
 and returns 
 on the wind of morning."

More information about the erlang-questions mailing list