Rascals are always sociable, and the chief sign that a man has any nobility in his character is the little pleasure he takes in others company. Arthur Schopenhauer

Hook Heaps and Live Free

Let’s talk a bit about why we want to encrypt heap allocations. Something I’m not going to go into too deeply is the difference between the stack and the heap. The stack is locally scoped and usually falls out of scope when a function completes. This means items set on the stack during the run of a function fall off the stack when the function returns and completes; this obviously isn’t great for variables you’d like to keep long term in memory. This is where the heap comes in. The heap is meant to be more of a long-term memory storage solution. Allocations on the heap stay on the heap until your code manually frees them. This can also lead to memory leaks if you continually allocate data onto the heap without ever freeing anything. Hook Heaps and Live Free