Boost logo

Boost Users :

From: Paul Giaccone (paulg_at_[hidden])
Date: 2007-04-19 11:25:19


Michael Fawcett wrote:
> On 4/19/07, Paul Giaccone <paulg_at_[hidden]> wrote:
>
>> If I've understood correctly, this means that any memory allocated on
>> the heap in MyNode must be done using bare pointers rather than smart
>> pointers, so that Maya can delete it when it wants, not when the smart
>> pointers say the memory can be released. MyNode and any objects that it
>> allocates on the heap still need to have destructors to deallocate their
>> contents, but it is up to Maya when the destructor for MyNode is called.
>>
>
> I don't think this is the case. MyNode's destructor will get called
> when Maya determines it's time to delete it, and any smart_ptr member
> variables will decrement their reference count. That's the ideal
> state of affairs, since it works as designed. The only difference is
> that MyNode pointers are created by a create function, and Maya cleans
> them up. You cannot attempt to manage MyNode pointers, since Maya
> determines their lifetime, however, you can (and should) manage
> anything not managed by Maya.
>
Well, I hope that's true, because I'm fiddling around with delete[],
etc, and my program is leaking memory like a sieve. Like in all those
washing powder commercials, there's no way I want the old brand back :)

It looks like I might have been doing something else wrong after all
that would cause a memory leak - copying pointers to arrays in a copy
constructor instead of allocating memory and then copying the array
elements.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net