I have an erlang gen_server which receives messages from clients asynchronously(using cast). On each message handling, the server inserts them into a ordered ETS table and deletes some of them based on conditions (Because of the conditional delete, the number of records in the ETS table is in most of the time around 5000. But there are rare scenarios which can increase this size up to 200k, introducing overhead for both inserts and deletes).
This works fine until messages per second is 100k but above this it gives me the process memory high watermark and starts consuming a lot of memory. When I comment out the insert and delete part to the ordered ets, it can process more than 100k per second. Can you please give me some hints on how to solve this?
Is there any maximum limit of memory that a process can allocate? I'm using 35 GB of Memory and I set the watermark threshold by memsup:set_procmem_high_watermark(0.6)
. I also tried gbtree and ordered dictionary but they didn't solve the memory error.