Thread: Free Store of memory

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    1,579

    Free Store of memory

    Hello everyone,


    I am learning the storage area of Windows memory, but I am not sure what is the usage for Free Store area, what is the differences between Free Store area and heap area?

    http://www.gotw.ca/gotw/009.htm

    --------------------
    Free Store The free store is one of the two dynamic memory
    areas, allocated/freed by new/delete. Object
    lifetime can be less than the time the storage
    is allocated; that is, free store objects can
    have memory allocated without being immediately
    initialized, and can be destroyed without the
    memory being immediately deallocated. During
    the period when the storage is allocated but
    outside the object's lifetime, the storage may
    be accessed and manipulated through a void* but
    none of the proto-object's nonstatic members or
    member functions may be accessed, have their
    addresses taken, or be otherwise manipulated.
    --------------------

    Could anyone provide more information or sample please?


    thanks in advance,
    George

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    In my 3rd Ed. of Bjarne Stroustrup's "The C++ Programming Language", section Appendix C, section C.9 it says "Typically, the free store (also called dynamic memory or the heap) ..." - so it seems like free store is a different name for heap.

    No, I haven't memorized the entire book, but I remembered reading that section when someone asked about "auto" recently.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Nov 2006
    Posts
    519
    Quote Originally Posted by George2 View Post
    The free store is one of the two dynamic memory areas, allocated/freed by new/delete.
    Hm, what is the second one?

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Hm, what is the second one?
    According to Herb Sutter in that article, it would be the heap.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Nov 2006
    Posts
    519
    erm, as matsp and all other references I know of pointed out, heap and free store does mean the same. so the first one is the free store and the second one is ... the free store??

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    erm, as matsp and all other references I know of pointed out, heap and free store does mean the same. so the first one is the free store and the second one is ... the free store??
    Read the article. This is Herb Sutter's opinion. I lack the expertise to provide an expert opinion on this subject.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  7. #7
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Actually, if you read the last few sentences, it becomes clear that the author distinguishes them, not so much as being different memory as such, but different "access functions". Free store is used by new & delete, heap is used by malloc & free. It also states that one can be implemented as the other in either direction (that is, new can be using malloc, or malloc could be using new).

    But the main difference is that you should not free a new'd allocation with free, nor should you free a malloc'd allocation with delete. It MAY work to do that, but it's definitely "undefined behaviour".

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Mutex and Shared Memory Segment Questions.
    By MadDog in forum Linux Programming
    Replies: 14
    Last Post: 06-20-2010, 04:04 AM
  2. free memory in structure
    By franziss in forum C++ Programming
    Replies: 22
    Last Post: 01-08-2007, 05:16 PM
  3. Free store vs. heap
    By CondorMan in forum C++ Programming
    Replies: 1
    Last Post: 08-07-2006, 11:41 AM
  4. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM
  5. Using extended memory to store program data
    By Robby in forum C Programming
    Replies: 1
    Last Post: 01-11-2005, 08:19 AM