diff --git a/src/mono/mono/metadata/loader.c b/src/mono/mono/metadata/loader.c index 921fe29e2743e1..58ccd6afd15a70 100644 --- a/src/mono/mono/metadata/loader.c +++ b/src/mono/mono/metadata/loader.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -1371,8 +1372,11 @@ mono_free_method (MonoMethod *method) MONO_PROFILER_RAISE (method_free, (method)); - /* FIXME: This hack will go away when the profiler will support freeing methods */ - if (G_UNLIKELY (mono_profiler_installed ())) + // EventPipe might require information about methods to be stored throughout + // entire app execution, so stack traces can be resolved at a later time. + // Same for debugger, we are being overly conservative + if (mono_component_event_pipe ()->component.available () || + mono_component_debugger ()->component.available ()) return; if (method->signature) {