Custom Allocators & Order Matching Engine

Four memory allocators (Linear, Stack, Pool and Free-List) written from scratch in C++, and a limit-order-book matching engine that uses them so the matching path never calls new or malloc.

4
Total Technologies
5
Key Features

Technologies Used

C++
Memory Management
Data Structures
Benchmarking
Custom Allocators & Order Matching Engine

Key Features

  • Pool allocator for orders: fixed-size blocks with the free list stored inside the free memory, so allocating and freeing an order is O(1) with no heap fragmentation.
  • Linear allocator as scratch space for each incoming order message, reset in O(1) once the message is processed.
  • Price-time-priority matching: buy orders kept highest-price-first and sell orders lowest-price-first; an incoming order fills against the best opposite price while prices cross.
  • Benchmarked 1M allocate/free operations (median of 7 runs, g++ -O2 on Linux): the pool allocator is ~2.5x and the linear allocator ~15x faster than glibc new/delete.
  • Stack (LIFO) and general-purpose Free-List (first-fit with coalescing) allocators share the same interface for side-by-side comparison.