I think that's the main leak we have in BS2 for quite some time, and the 
most severe in CLucene. I'll be wrong only if there's another such leak 
in BS2 :)


Why isn't using a smart pointer? aren't scorers some of the objects you 
wrapped with smart pointers?


Itamar.


On 18/03/2011 16:51, Veit Jahns wrote:

> Hi all,
>
> recently I continued to work on the smart_pointers branch and
> discovered a memory leak in BooleanScorer2.cpp, lines 610--624:
>
> [...]
>       if ( _internal->allowDocsOutOfOrder&&
> _internal->requiredScorers.size() == 0&&
> _internal->prohibitedScorers.size()<  32 ) {
>
>               BooleanScorer* bs = _CLNEW BooleanScorer( getSimilarity(),
> _internal->minNrShouldMatch );
>               Internal::ScorersType::iterator si = 
> _internal->optionalScorers.begin();
>               while ( si != _internal->optionalScorers.end() ) {
>                       bs->add( (*si), false /* required */, false /* 
> prohibited */ );
>                       si++;
>               }
>               si = _internal->prohibitedScorers.begin();
>               while ( si != _internal->prohibitedScorers.end() ) {
>                       bs->add( (*si), false /* required */, true /* 
> prohibited */ );
>                       si++;
>               }
>               bs->score( hc );
>       } else {
> [...]
>
> Here bs is created, but never deleted. But if I add a delete after the
> score() the tests testBooleanScorer2WithProhibitedScorer fails,
> because bs takes the ownership of the optional and prohibited scorers,
> i.e., deleting bs deletes also these scorers. This also means that
> these scorers can't be reused. My first idea was, to remove the
> corresponding deletes in BooleanScorer/SubScorer. But then I get
> errors on other places in BooleanScorers due to double deletes, etc.
> It seems to me that only BooleanScorer should have the ownership of
> this subscorers.
>
> Any ideas, comments on this?
>
> Kind regards,
>
> Veit
>
> ------------------------------------------------------------------------------
> Colocation vs. Managed Hosting
> A question and answer guide to determining the best fit
> for your organization - today and in the future.
> http://p.sf.net/sfu/internap-sfd2d
> _______________________________________________
> CLucene-developers mailing list
> CLucene-developers@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/clucene-developers
>
>

------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software 
be a part of the solution? Download the Intel(R) Manageability Checker 
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
CLucene-developers mailing list
CLucene-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/clucene-developers

Reply via email to