Free store vs. heap

This is a discussion on Free store vs. heap within the C++ Programming forums, part of the General Programming Boards category; I've been going through some tutorials and a book on C++ and in some, there is an interchange between the ...

  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    23

    Free store vs. heap

    I've been going through some tutorials and a book on C++ and in some, there is an interchange between the heap and free store terminology. One of them, however, says that they are not the same thing. It suggests that the free store is used in C++ and memory is allocated and freed using NEW and DELETE, whilst the heap is used in C and memory is allocated and freed using MALLOC and FREE. I am not familiar with the latter keywords as I have no experience of C, having decided to jump straight into C++.

    Are the free store and heap interchangeable or are the distinctions mentioned above correct? If they are correct, I assume that keywords can't be mixed i.e. memory can't be allocated with MALLOC and freed with DELETE or allocated with NEW and freed with FREE?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,852
    > Are the free store and heap interchangeable or are the distinctions mentioned above correct?
    Pretty much the same thing as far as I'm concerned.
    New (c++) can be thought of as calling malloc (c), followed by calling appropriate constructors. Indeed in some systems this is how it is implemented.

    In pretty much every system, both end up calling some base level "get memory from the OS and allocate as needed" type of memory pool management.

    > I assume that keywords can't be mixed
    Correct.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. lots of freeware
    By major_small in forum General Discussions
    Replies: 58
    Last Post: 2 Weeks Ago, 11:27 PM
  2. Understanding the stack and heap
    By yougene in forum C Programming
    Replies: 4
    Last Post: 01-19-2009, 05:22 AM
  3. Fixing my program
    By Mcwaffle in forum C Programming
    Replies: 5
    Last Post: 11-05-2008, 03:55 AM
  4. Stack and Free Store Objects
    By Frank_Li in forum C++ Programming
    Replies: 9
    Last Post: 05-16-2006, 02:37 PM
  5. Program that displays amount of free memory
    By trancedeejay in forum Linux Programming
    Replies: 3
    Last Post: 01-13-2006, 01:27 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21