From 134916cf6d70f26fb9a6da0a5d7d6d764bb21406 Mon Sep 17 00:00:00 2001 From: Erik Garrison Date: Mon, 23 Sep 2019 17:13:17 +0200 Subject: [PATCH] resolve memory leaks in mapper (resolves #2421) --- src/cluster.cpp | 6 +++--- src/subcommand/map_main.cpp | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/cluster.cpp b/src/cluster.cpp index 187d7e96c04..8062bb1895b 100644 --- a/src/cluster.cpp +++ b/src/cluster.cpp @@ -3521,9 +3521,9 @@ bdsg::HashGraph cluster_subgraph_containing(const HandleGraph& base, const Align backward_max_dist.push_back(aligner->longest_detectable_gap(aln, mem.begin) + (mem.begin - aln.sequence().begin())); } - auto cluster_graph = new bdsg::HashGraph(); - algorithms::extract_containing_graph(&base, cluster_graph, positions, forward_max_dist, backward_max_dist); - return *cluster_graph; + auto cluster_graph = bdsg::HashGraph(); + algorithms::extract_containing_graph(&base, &cluster_graph, positions, forward_max_dist, backward_max_dist); + return cluster_graph; } bdsg::HashGraph cluster_subgraph_walk(const HandleGraph& base, const Alignment& aln, const vector& mems, double expansion) { diff --git a/src/subcommand/map_main.cpp b/src/subcommand/map_main.cpp index b1c0b6ab82d..e74106f53ad 100644 --- a/src/subcommand/map_main.cpp +++ b/src/subcommand/map_main.cpp @@ -1217,6 +1217,11 @@ int main_map(int argc, char** argv) { cout.flush(); + // clean up our mappers + for (uint64_t i = 0; i < mapper.size(); ++i) { + delete mapper[i]; + } + return 0; }