Aussie AI

Stack Memory Management

  • Book Excerpt from "Advanced C++ Memory Techniques: Efficiency and Safety"
  • by David Spuler, Ph.D.

Stack Memory Management

It is less commonly used, but possible, to dynamically allocate stack memory. Functions include:

  • alloca — the main stack memory allocation function (<alloca.h>.
  • _malloca — stack memory allocation (Microsoft CRT)
  • _freea — free memory on the stack or heap (Microsoft CRT)
  • __builtin_alloca_with_align (GCC version with alignment)

Note that “de-allocation” of a stack block is technically not required, because the memory is reclaimed when the function returns and the stack is unwound.

 

C++ Memory Techniques Book:

Online: Table of Contents

PDF: Free PDF book download

Buy: Advanced C++ Memory Techniques: Efficiency and Safety

Advanced C++ Memory Techniques Advanced C++ Memory Techniques: Efficiency & Safety:
  • Memory optimization techniques
  • Memory-efficient data structures
  • DIY memory safety techniques
  • Intercepting memory primitives
  • Preventive memory safety
  • Memory reduction optimizations

Get your copy from Amazon: Advanced C++ Memory Techniques