Allocators and Where Memory Comes From
Custom allocators are a recurring topic at the lowest-latency shops, and the question is rarely "write one". It is "why would you", which is a question about what the default one does.
What new costs
new calls the global allocator, which maintains free lists across size classes, takes a lock or consults a per-thread cache, may split or coalesce blocks, and occasionally asks the operating system for more address space. Tens to a couple of hundred nanoseconds, unpredictably, with the tail far worse than the median.
That variance is the objection, not the mean. A path with a latency budget measured in microseconds cannot contain an operation whose 99th percentile is fifty times its median, and the request that triggers a new page from the kernel is exactly the one that lands during a burst.
The rest of this lesson is for subscribers
Unlock every lesson in Systems Programming for Trading, and every other premium course.
Subscribe to continueTest your knowledge
Keep reading Systems Programming for Trading
19 lessons in this course, and every other premium course, on one subscription.
- Every lesson in every course, with the worked examples and interactive simulators
- Graded questions on every lesson, with explanations for the wrong answers as well as the right one
- The trainers, timed assessments and brainteaser library that go with them