Stack vs Heap. What’s the difference and why should I care?

This article explains in depth:

What are the five segments of memory?

What is the stack?

Program vs Stack usage
Yes, I have a whiteboard on the back of my door at my house.
Stack size is 8.192MB of memory.

What is the heap?

Allocating 4000 bytes of memory to our program, then releasing it.
Valgrind being used. 4,000 bytes allocated. 0 bytes leaks

How does understanding the stack and heap make you a better software engineer?

Photo credit: Gribble Lab

References:

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store