Free Store is a pool of un-allocated heap memory given to a program that is used by the program for dynamic allocation during the execution of program. Every program is provided with a pool of un-allocated heap memory that it may utilize during the execution.
The “free store” is just another name for the heap. It is an area of memory that is used for dynamic allocation of memory while the program is running (i.e., at run time). Dynamic allocation of memory from the heap allows us to create, use, and dispose of objects as needed.
The heap is a memory used by programming languages to store global variables. By default, all global variable are stored in heap memory space. It supports Dynamic memory allocation. The heap is not managed automatically for you and is not as tightly managed by the CPU. It is more like a free-floating region of memory.
In C, dynamic memory is allocated from the heap using some standard library functions. The two key dynamic memory functions are malloc() and free(). The malloc() function takes a single parameter, which is the size of the requested memory area in bytes.
Originally a pedantics war on @Als answer here, it also sparked a discussion in the C++ chatroom.
This article by Herb Sutter distinguishes between the two, but is also over a decade old, as it clearly was written before 2000 and also talks about the standard draft, which can only mean C++98 draft. Though, I still expect Herb, as part of the committee, to be knowledgeable about this stuff.
I know of this and this question/answer, but the second just cites Herb's article while the first cites another source that simply rejects the use of the term "heap", aka they are both not exactly satisfactory. Also, I can't find any free-store
or freestore
tag on SO (until this question, I created the former one now).
Now, what is really the difference, if any?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With