Skip to content

Commit a8cab47

Browse files
richard-finejoncham
authored andcommitted
Free coverage data when unloading a method
1 parent 2a962ad commit a8cab47

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

mono/metadata/profiler-private.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ mono_profiler_installed (void)
113113
}
114114

115115
MonoProfilerCoverageInfo *mono_profiler_coverage_alloc (MonoMethod *method, guint32 entries);
116+
void mono_profiler_coverage_free (MonoMethod* method, MonoProfilerCoverageInfo* info);
116117

117118
struct _MonoProfilerCallContext {
118119
/*

mono/metadata/profiler.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,20 @@ mono_profiler_coverage_alloc (MonoMethod *method, guint32 entries)
564564
return info;
565565
}
566566

567+
void mono_profiler_coverage_free (MonoMethod* method, MonoProfilerCoverageInfo* info)
568+
{
569+
if (!mono_profiler_state.code_coverage)
570+
return;
571+
572+
coverage_lock ();
573+
574+
g_hash_table_remove(mono_profiler_state.coverage_hash, method);
575+
576+
coverage_unlock ();
577+
578+
g_free (info);
579+
}
580+
567581
/**
568582
* mono_profiler_enable_sampling:
569583
*

mono/mini/mini.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1908,6 +1908,11 @@ mono_empty_compile (MonoCompile *cfg)
19081908
}
19091909
cfg->headers_to_free = NULL;
19101910

1911+
if (cfg->coverage_info) {
1912+
mono_profiler_coverage_free(cfg->method, cfg->coverage_info);
1913+
cfg->coverage_info = NULL;
1914+
}
1915+
19111916
if (cfg->mempool) {
19121917
//mono_mempool_stats (cfg->mempool);
19131918
mono_mempool_destroy (cfg->mempool);

0 commit comments

Comments
 (0)