~/talk

Heaps Don’t Lie - Guidelines for Memory Allocation in C++

Talkat ACCU 2025 · 2025-04-01..04-04· [c-and-cpp]
slides:none on file

Claims ten concrete rules: prefer stack allocation because it’s a one-register add; avoid malloc in hot/parallel sections because system calls and swapping can be ~10x–1000x slower and cause millisecond stalls; Windows CRT malloc serializes (use mimalloc as a drop-in); reserve containers when final size is known but don’t overuse reserve in tight loops; prefer output-parameter reuse to returning temporary vectors; consider a monotonic allocator/PMR for scoped, budgeted workloads but avoid reimplementing a full malloc.

AI-written summary · about

  1. 0:00Introduction
  2. 0:57Heaps don't lie
  3. 4:13Understanding allocation
  4. 6:32Stack allocation
  5. 9:26Stack limitations
  6. 11:39Heap allocation basics
  7. 13:16Malloc performance
  8. 19:38Custom allocators
  9. 21:56Windows allocation issues
  10. 25:30Allocation pitfalls
  11. 29:12Pathfinding example
  12. 33:15Reserve vs growth
  13. 36:43Optimizing search
  14. 39:24Output parameters
  15. 40:56Reusing memory
  16. 43:04Clearing structures
  17. 46:05Memory management
  18. 50:08Custom allocators
  19. 51:22Dynamic stack memory
  20. 52:38Alloca pitfalls
  21. 55:11Monotonic allocator
  22. 1:00:00Budgeting resources
  23. 1:01:56Free lists
  24. 1:05:55Conclusion
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.