Every day spent coding is different thanks to the NULL pointer.
There are three types of memory usage when using C++. They are static, stack and heap.
Static memory is the ones allocated to the program when it start to store the code and the global structures that it use.
Used to store function return addresses, functions arguments and variables declared local in a functions. The stack has a limited size and if the big local variables are created or to much recursion there will be a stack overflow.
In C++ the memory from the heap is allocated with new and when it is not needed anymore it is removed with delete.
new / delete
Overloading New / Delete
It is possible to overload new and delete so custom actions is taken when you try to get memory for something.
malloc / free
calloc / realloc
Heap Memory Management
With a memory pool you keep a a maximum number of objects you need allocated all the time. Ex if you make a space shooter you have 100 laser bolt objects allocated in a array. When you need one you can simple get a pointer to one not in use and when the bolt is destroyed you can flag it as not in use and let it be. That way one does not have to new and delete the memory for them, something that can get expansive when the player spray the world with his laser gatling gun.
- Data structure alignment
- Building a Low-Fragmentation Memory System for 64-bit Games - 2016
- Allocation Adventures - 2015: Part 1 , Part 2
- Memory Management: Pool Allocator - 2014
- Memory Management: Slab allocator - 2014
- Memory Management: the SLUB allocator - 2014
- Memory Management - 2014
- C++: Custom memory allocation - 2013
- Memory System - 2013
- Memory Management Strategies - 2012
- Memory allocation strategies - 2012
- Memory allocation strategies: a growing stack-like (LIFO) allocator
- Memory allocation strategies interlude: virtual memory
- Memory allocation strategies: a pool allocator
- Memory allocation strategies: a stack-like (LIFO) allocator
- Memory allocation strategies: a linear allocator
- Scope Stack Allocation - 2010
- Memory system: Part 1, Part 2, Part 3 and Part 4. - 2011
- Debugging Memory Corruption in Game Development - 2008
- Virtual Memory System on Nintendo Gamecube - 2007
- Alternatives to malloc and new
- Memory Pool
Virtual memory explained - 2015
A memory allocator interface - 2015
Caches everywhere - 2015
gin - 2015
Introduction - 2011
Allocations Tracking - 2011
Memory Allocators Design - 2011
Garbage collection thoughts - 2012
Virtual Addressing 101 - 2011
Virtual Memory Tricks - 2017
Memory Management - 2014
Freelist Concept - 2015
A queue of page faults- 2014
Writing Cache-Friendly C++ - 2018