Reported by bianjiang on 19 Apr 43883161 15:53 UTC
See attached file...
Looks like NeighborSearch.Search() is leaking memory.
Commented by bianjiang on 27 Dec 43883163 12:49 UTC
gcc-4.8; mac os x;
Commented by bianjiang on 16 Jan 43883223 04:19 UTC
Apparently, if you pass in a referenceTree, rather than just use the constructor, it doesn't leak... The following code if fine.
AllkNN* allknn = NULL;
refTree(data, oldFromNewRefs, leafSize);
allknn = new AllkNN(&refTree, data, false);
Trees created from the following constructor not being deleted?
// Construct the object.
template<typename SortPolicy, typename MetricType, typename TreeType>
NeighborSearch<SortPolicy, MetricType, TreeType>::
NeighborSearch(const typename TreeType::Mat& referenceSet,
const typename TreeType::Mat& querySet,
const bool naive,
const bool singleMode,
const size_t leafSize,
const MetricType metric) :
treeOwner(true), // False if a tree was passed.
singleMode(!naive && singleMode), // No single mode if naive.
// C++11 will allow us to call out to other constructors so we can avoid this
// copypasta problem.
// We'll time tree building, but only if we are building trees.
// Construct as a naive object if we need to.
referenceTree = new TreeType(referenceCopy, oldFromNewReferences,
(naive ? referenceCopy.n_cols : leafSize));
queryTree = new TreeType(queryCopy, oldFromNewQueries,
(naive ? querySet.n_cols : leafSize));
// Stop the timer we started above (if we need to).
Commented by rcurtin on 30 Nov 43884642 23:29 UTC
Thank you for pointing this out. I believe I have fixed the issue in r16041, although I was unable to run the test you gave (it never terminated; that could be setup-specific though). Anyway, valgrind reports no errors for the AllkNN tests as of r16041, whereas it did before. The issue was that some matrices used to remap points to their original indices were not being deleted.
If the problem isn't fixed, feel free to reopen the bug, and if you have further problems, feel free to open other bugs.