[mini] Shut down the profiler after shutting down the major runtime components.
[mono.git] / mono / mini / mini-runtime.c
index fdb1669c807f9f7defb1a6a9cc0fb88d51884bc0..795bab9e41d319ebb23ec690c14ee6cf6c288980 100644 (file)
@@ -4164,7 +4164,8 @@ print_jit_stats (void)
 void
 mini_cleanup (MonoDomain *domain)
 {
-       mono_runtime_shutdown_stat_profiler ();
+       if (mono_profiler_get_events () & MONO_PROFILE_STATISTICAL)
+               mono_runtime_shutdown_stat_profiler ();
 
 #ifndef DISABLE_COM
        cominterop_release_all_rcws ();
@@ -4181,12 +4182,12 @@ mini_cleanup (MonoDomain *domain)
        /* This accesses metadata so needs to be called before runtime shutdown */
        print_jit_stats ();
 
-       mono_profiler_shutdown ();
-
 #ifndef MONO_CROSS_COMPILE
        mono_runtime_cleanup (domain);
 #endif
 
+       mono_profiler_shutdown ();
+
        free_jit_tls_data ((MonoJitTlsData *)mono_native_tls_get_value (mono_jit_tls_id));
 
        mono_icall_cleanup ();