zettelkasten
Free Store Manager
Last updated: 1/9/2025
The free store manager is the thing that allocates memory to the free store in [[c]]
Something very important to know about some C++ keywords that regard the free store manager is that they don't work like they seem to:
c++
int* p = new int{4}; // new keyword returns the address of the dynamically allocated integer object.delete p; // This doesn't get rid of the p pointer, it deallocates the dynamically allocated integer object.p = nullptr; // Makes it so that p no longer points to the previous address SUPER IMPORTANT
int* arr = new int[kSize]; // Allocates an array of integers on free storedelete[] arr; // Deletes arrays
int** arr = new int*[kColumns]; // Allocates kColumns of integer arrays on free store;
// Now you have to create each row of the array like:arr[0] = new int[kRows];
// For deletion make sure you delete each row and then each column of the array with a for loop
With the Free Store Manger a good rule of thumb is to have equal amounts of news and deletes or else your program is INVALID.
See Also
- [[computer-science]]