Re: 0.3.12 test tarballs

Posted by Luigi Ballabio on
URL: http://quantlib.414.s1.nabble.com/0-3-12-test-tarballs-tp10998p11004.html

On 02/23/2006 01:22:42 PM, eric ehlers wrote:
> I don't know about VC8 Pro but valgrind detects the memory leak at
> line 95 of libormarketmodelprocess.cpp, the full output is below.
>
> I haven't had time to investigate further but a first guess would be
> that maybe the shared pointer to the LiborForwardModelProcess object
> is used incorrectly such that the reference counting is circumvented
> preventing the object from being deleted when the pointer goes out of
> scope.

Ok, I see. There's a circular reference. First the shared_ptr to  
process is passed to fct, which stores it. Then fct is passed to  
process through setCovarParam and stored in turn. As process and fct  
hold shared_ptrs to each other, neither reference count will ever reach  
0 and the allocated memory will never be freed.

Klaus, is the circularity necessary in the test---or in real life? If  
so, we'll have to think of a way to break the cycle; a weak_ptr would  
be the obvious choice.

Later,
        Luigi


----------------------------------------

A debugged program is one for which you have not yet found the
conditions that make it fail.
-- Jerry Ogdin