summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/map.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2010-07-30 18:31:28 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2010-07-30 18:31:28 -0300
commitd65a458b348cd458413b3cfec66e43ebd0367646 (patch)
tree984d730e5a81e4ae7c04b9f664d8a1cacdd0c6e6 /tools/perf/util/map.c
parent591765fdaf7ea1888157f342b67b0461f2e5ed9b (diff)
perf tools: Release session and symbol resources on exit
So that we reduce the noise when looking for leaks using tools such as valgrind. Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> LKML-Reference: <new-submission> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/map.c')
-rw-r--r--tools/perf/util/map.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 2ddbae319de..15d6a6dd50c 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -539,6 +539,32 @@ int machine__init(struct machine *self, const char *root_dir, pid_t pid)
return self->root_dir == NULL ? -ENOMEM : 0;
}
+static void dsos__delete(struct list_head *self)
+{
+ struct dso *pos, *n;
+
+ list_for_each_entry_safe(pos, n, self, node) {
+ list_del(&pos->node);
+ dso__delete(pos);
+ }
+}
+
+void machine__exit(struct machine *self)
+{
+ struct kmap *kmap = map__kmap(self->vmlinux_maps[MAP__FUNCTION]);
+
+ if (kmap->ref_reloc_sym) {
+ free((char *)kmap->ref_reloc_sym->name);
+ free(kmap->ref_reloc_sym);
+ }
+
+ map_groups__exit(&self->kmaps);
+ dsos__delete(&self->user_dsos);
+ dsos__delete(&self->kernel_dsos);
+ free(self->root_dir);
+ self->root_dir = NULL;
+}
+
struct machine *machines__add(struct rb_root *self, pid_t pid,
const char *root_dir)
{