Closed xanderdunn closed 2 years ago
This was a mistake on my part - the environment I was running it in had a limit on heap page allocation and it was being killed when it attempted to exceed that memory limit. Simply lifting the memory limit prevents the segfault.
I am consistently getting a segfault after some millions of calls to
AddOrder
:It looks like it is this call.
I have many threads that are receiving orders, creating
CppTrader::Matching::Order
objects, and placing them into a FIFO concurrent queue:orders_queue.enqueue(order)
. However, reads from the queue and calls toAddOrder
are only ever done by a single thread:Something strange I notice is that the segfault occurs at about the same point in execution on every run. I print some order book stats every 5 seconds, and it's always around the same number of orders processed before segfault:
All orders are either buy or sell limit orders. The price and quantity values are randomly generated ints from 1 to 1000.
Do you have any recommendations on how I might be incorrectly handling the memory management of my
Order
s, or other ideas on what might cause this?