Open azmfaridee opened 11 years ago
I think DecisionTree already has a destructor. Do we need to call this explicitly?
@kdiverson I know which one you are referring to: https://github.com/darthxaher/mothur/blob/master/decisiontree.hpp#L42
My point is that since in the line: https://github.com/darthxaher/mothur/blob/master/randomforest.cpp#L124
we are creating new decision tree, by using dynamic memory alloc, the destructor will of DecisionTree will not be called, this needs to be done explicitly in RandomForest's destructor, otherwise the memory allocated by new will not be freed automatically.
@mothur-westcott Did not encounter this problem as she is working in Mac OSX, this is because Mac OSX automatically does a memory sweep in OS level which is kinda like a garbage collector regardless of the programming language usage, but in Linux or other OS you'll surely run into bugs because of this, I have tested this and I can tell.
@darthxaher https://github.com/darthxaher/mothur/blob/master/randomforest.hpp#L31
the destructor is commented out
Memory does not get released after running the program.
In the function int RandomForest::populateDecisionTrees() there is a memory allocation like this:
But this does not get deleted in any of the further commands because that has been removed from the code in some points.