devxlogo

Free Store and Heap

Free Store and Heap

Question:
Is there any difference between heap and free store in C++?

Answer:
The free store is a region of memory from which a program allocates dynamic memory using new. In most cases, the free store is implemented as a heap. Therefore, each allocation request returns a memory address that is higher than the previous one (as opposed to a stack, for instance). The terms “free store” and “heap” are often used interchangeably in the literature although technically, the free store needn’t be implemented as a heap. Note also that “free store” is only applicable to C++. In C, the region of dynamic memory available at runtime is called “the heap” and is allocated using malloc() or calloc(). Note that malloc() and new might access two different memory heaps. Therefore, you shouln’t relase memory allocated using malloc() with delete or call free() to release memory allocated using new.

See also  Professionalism Starts in Your Inbox: Keys to Presenting Your Best Self in Email
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist