On 15 Oct 2003 03:08:52 -0700,
(Megha Vishwanath)
wrote:
>Hi,
>
>I'd like to know how heap aggregates created with a "new" operator at
You mean the new[] operator?
>non-contiguous memory locations get deallocated using the "delete []"
>operator in VC++.
There is a header before the bit of memory that new[] returns that
gives the size of the allocated block. A call to delete[] then uses
this size to
a) work out how many objects to destruct
b) actually deallocate the memory
>A garbage collectors in Java deallocate on the basis of a record
>maintained during the "new" allocation.
Same in C++ - the memory allocator keeps track of the size of
allocations. Different allocators do this differently.
>
>Do we use something like a garbage collector to maintain arecord of
>the heap memory start indexes.
No. You should read up on memory allocators:
http://www.memorymanagement.org
Tom