Re: Free Store of memory
- From: "Igor Tandetnik" <itandetnik@xxxxxxxx>
- Date: Mon, 12 Nov 2007 08:28:24 -0500
"George" <George@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:703C8DE6-9A5D-43E3-A007-D303B49B7D20@xxxxxxxxxxxxx
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
The article makes a somewhat artificial distinction between memory
allocated by new and deallocated by delete (which it calls "free store")
and memory allocated by malloc and deallocated by free ("heap"). The
term "free store" is used in the C++ standard to describe a concept that
pretty much everybody calls "heap". I suspect this is done to avoid
confusion with a data structure also called "heap" (which has nothing at
all to do with memory allocation) - see make_heap et al.
In most implementations, new uses malloc internally, and delete uses
free, so there's just a single area of memory from which both kinds of
allocations come from. The standard explicitly allows new and delete to
be implemented this way. The standard doesn't require it though, so in
principle a legal implementation can maintain two separate areas
(personally, I don't know of any such implementation).
My guess is, the article emphasizes the two "separate" memory areas to
drive home an important point that you can't mix allocation functions:
memory allocated with new must be deallocated with delete, allocated
with new[] deallocated with delete[], and allocated with malloc and
variants deallocated with free.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
.
- Prev by Date: Re: platform specific API or C standard API
- Next by Date: Re: find the largest 1000 values
- Previous by thread: platform specific API or C standard API
- Next by thread: Re: Free Store of memory
- Index(es):
Relevant Pages
|