 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Kavya Guest
|
Posted: Mon Oct 30, 2006 9:29 am Post subject: new/malloc & free store/heap |
|
|
I always thought heap and free store is same thing but I recently
starting hearing from people that these are different terms. They say
new uses free store and malloc/calloc/realloc uses heap.
Can someone through some light on this issues with some standard
reference if possible. |
|
| Back to top |
|
 |
Old Wolf Guest
|
Posted: Mon Oct 30, 2006 10:10 am Post subject: Re: new/malloc & free store/heap |
|
|
Kavya wrote:
| Quote: | I always thought heap and free store is same thing but I recently
starting hearing from people that these are different terms. They say
new uses free store and malloc/calloc/realloc uses heap.
Can someone through some light on this issues with some standard
reference if possible.
|
Generally, the two terms are interchangeable, when referring to
the free store.
A "heap" is a data structure which is sorted so that each node
is (greater | less than) all of its children. The term has come to
be synonymous with free store because traditional memory
allocators stored the list of free memory blocks in a heap structure.
However, some people prefer to say "free store" because modern
memory allocators may not use a heap structure, so it is not
very accurate to call them a "heap".
On any particular system, you may or may not find that new and
malloc allocate memory out of the same memory pool (whatever
you might call that pool). They might do, or they might not. Which
is why you should be careful to match new with delete, and malloc
with free. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|