Keep in mind my examples are all coming from quant finance use cases. I'm sure sir Avi and Prof Duffy can highlight other cases.
Large Data Structures: Use heap memory for order books, price matrices, and data structures that handle historical price data, as these can easily grow large with high-frequency trading data or long backtesting periods. Learned this lesson all too painfully!
Dynamic Sizing: In finance applications since we often deal with datasets of unknown or varying size (e.g., market data, trades, or order flow), the heap is useful when data structures need to expand dynamically.
Persistence Across Trades and Positions: If an object, like a position or a trade, needs to persist beyond a single function or class, allocate it on the heap to ensure it remains accessible across modules or parts of your application.
Parallel Processing: For multi-threaded operations, like parallelized Monte Carlo simulations or batch processing of trades, heap allocation allows shared data structures to be accessed safely by multiple threads. This one is a life saver to remember.
Optimization with Custom Allocators: In performance-sensitive areas, custom allocators (often used with heap-allocated data) can optimize latency and memory layout, crucial for low-latency trading systems or real-time risk calculations. Sir Avi might have specific ideas from FX high frequency land.
Avoiding Stack Overflow: For deeply nested calculations or recursive functions, especially in algorithmic trading, use the heap to avoid stack overflow risks when handling complex data structures.
Library and API Interactions: Many finance libraries (like QuantLib) use heap allocation for compatibility and extensibility, particularly for structures that require frequent updates, such as option pricing trees or volatility surfaces. Quantlib is a great lib to play with also btw.
By no means a complete list but hopefully tickles the brain a bit to get you thinking about these type of things.