Merge pull request #1926 from alexrp/profiler-improvements
[mono.git] / mono / metadata / threads.c
index 95219a5482094233473f83072361e22fa79c56d7..ded97fdf404c15e31bc2115269e041b7b740f854 100644 (file)
@@ -2584,6 +2584,24 @@ ves_icall_System_Runtime_Remoting_Contexts_Context_RegisterContext (MonoAppConte
        g_hash_table_insert (contexts, gch, gch);
 
        mono_threads_unlock ();
+
+       mono_profiler_context_loaded (ctx);
+}
+
+void
+ves_icall_System_Runtime_Remoting_Contexts_Context_ReleaseContext (MonoAppContext *ctx)
+{
+       /*
+        * NOTE: Since finalizers are unreliable for the purposes of ensuring
+        * cleanup in exceptional circumstances, we don't actually do any
+        * cleanup work here. We instead do this when we iterate the `contexts`
+        * hash table. The only purpose of this finalizer, at the moment, is to
+        * notify the profiler.
+        */
+
+       //g_print ("Releasing context %d in domain %d\n", ctx->context_id, ctx->domain_id);
+
+       mono_profiler_context_unloaded (ctx);
 }
 
 void