[erlang-questions] Memory-effective queue handling

Erik Søe Sørensen eriksoe@REDACTED
Tue Jul 24 20:36:43 CEST 2012


Den 24/07/2012 17.11 skrev "Attila Rajmund Nohl" <attila.r.nohl@REDACTED>:
>
> Hello!
>
> I have a data structure where I manage "historical data": a list of
> timestamps when events happened. I only need to know how many events
> happened in the last 24 hours. When an event happens, I put the
> timestamp into the queue (I use the queue module in OTP). When I check
> how many values are in the queue, I also remove the entries that are
> older than 24 hours. My problem is: when I remove the old elements, I
> can do it one by one and at each step the (possibly big) queue gets
> copied and I run out of memory.
I am curious: how do you manage to do this? Can we see the code?
(Certainly it shouldn't be the case that much copying should be done at
each step.)

> Is there a cleverer way to remove
> elements from queue? Or maybe I shall use an ordered_set ETS table
> instead of a queue?
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120724/b8a7245e/attachment.htm>


More information about the erlang-questions mailing list