[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: memory debugging and C++ (program keeps crashing)



On Sun, Sep 29, 2002 at 04:38:06PM -0500, Shyamal Prasad wrote:
>     "Marc" == Marc Singer <elf@buici.com> writes:
> 
>     Marc> Actually, with GCC it doesn't matter which call you use.
>     Marc> New uses the malloc function.  You can free () or delete
>     Marc> memory allocated with malloc () or new.  New and delete are
>     Marc> 'syntactic sugar' for malloc and free.
> 
> You mean that very loosely, right? new and delete call constructors
> and destructors respectively. This is particularly important when you
> do stuff like delete [].

Indeed.  I mean that the memory is allocated and freed through the
same mechanisms.  Unlike other operating systems, there is usually
only one heap per process.  In the absence of constructors and
destructors, the calls are interchangeable.



Reply to: