# TMVA::Reader destructor issue

**URL:** <https://root-forum.cern.ch/t/tmva-reader-destructor-issue/17931>\
**Category:** TMVA\
**Created:** [July 18, 2014, 9:06am UTC](https://root-forum.cern.ch/t/tmva-reader-destructor-issue/17931 "2014-07-18T09:06:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Baptlagagne](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/b/3e96dc/32.png) [@Baptlagagne](https://root-forum.cern.ch/u/Baptlagagne)\
**Post date:** [July 18, 2014, 9:06am UTC](https://root-forum.cern.ch/t/tmva-reader-destructor-issue/17931/1 "2014-07-18T09:06:18Z")

</div>

Dear members of the root support,

In the code we develop, we have to call many times TMVA::Reader. It’s appear that a huge memory leak happend due to an undeleted map (fMethodMap) in the destructor (TMVA::~Reader). This memory leak causing my OS (Ubuntu 12.04) to freeze I had to track the leak and finally I propose this solution :  
in file $ROOTSYS/tmva/src/Reader.cxx

[code]TMVA::Reader::~Reader( void )  
{  
// destructor

delete fDataSetManager; // DSMTEST

delete fLogger;

std::map\<TString, IMethod\* \>::iterator it\_del;  
for( it\_del = fMethodMap.begin(); it\_del != fMethodMap.end(); it\_del++)  
{  
delete (\*it\_del).second;  
(\*it\_del).second = 0;  
}  
fMethodMap.clear();  
}[/code]

Will you envisage to correct this bug in a futur release ?  
Thank you for your consideration  
Best regards  
PS : my root environment :  
“TMVA Release” value=“4.1.4  
"ROOT Release” value="5.34/10

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [August 5, 2014, 3:09pm UTC](https://root-forum.cern.ch/t/tmva-reader-destructor-issue/17931/2 "2014-08-05T15:09:15Z")

</div>

Hi Baptiste,

thanks a lot for your report and proposed fix. I could as well see some memory leaks.  
I filed a report in our ticketing system for the TMVA author to study and potentially fix:  
[sft.its.cern.ch/jira/browse/ROOT-6551](https://sft.its.cern.ch/jira/browse/ROOT-6551)

Cheers,  
Danilo

---

<div class="post-metadata">

**Author:** ![Baptlagagne](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/b/3e96dc/32.png) [@Baptlagagne](https://root-forum.cern.ch/u/Baptlagagne)\
**Post date:** [November 28, 2014, 2:20pm UTC](https://root-forum.cern.ch/t/tmva-reader-destructor-issue/17931/3 "2014-11-28T14:20:29Z")

</div>

Dear Danilo,

I saw that the patch I propose is now in the version 5.34/23 and above.  
Would you mind to set the status of this post to solved ?

Thank you  
Cheers

Baptiste

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [November 28, 2014, 4:10pm UTC](https://root-forum.cern.ch/t/tmva-reader-destructor-issue/17931/4 "2014-11-28T16:10:41Z")

</div>

Done.
