From 1d309439cbdaa21a75731bd8db28217690e829a2 Mon Sep 17 00:00:00 2001 From: Ignacio Etcheverry Date: Thu, 5 Oct 2017 00:12:36 +0200 Subject: [PATCH] Uninitialized local and domain finalize fixes - Make sure to run the GC before and after finalizing the scripts domain. --- modules/mono/mono_gd/gd_mono.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp index 77f01842bbb..d0b5b12d4bf 100644 --- a/modules/mono/mono_gd/gd_mono.cpp +++ b/modules/mono/mono_gd/gd_mono.cpp @@ -31,6 +31,7 @@ #include #include +#include #include "os/dir_access.h" #include "os/file_access.h" @@ -272,7 +273,7 @@ bool GDMono::_load_assembly(const String &p_name, GDMonoAssembly **r_assembly) { if (OS::get_singleton()->is_stdout_verbose()) OS::get_singleton()->print((String() + "Mono: Loading assembly " + p_name + "...\n").utf8()); - MonoImageOpenStatus status; + MonoImageOpenStatus status = MONO_IMAGE_OK; MonoAssemblyName *aname = mono_assembly_name_new(p_name.utf8()); MonoAssembly *assembly = mono_assembly_load_full(aname, NULL, &status, false); mono_assembly_name_free(aname); @@ -438,10 +439,14 @@ Error GDMono::_unload_scripts_domain() { if (mono_domain_get() != root_domain) mono_domain_set(root_domain, true); + mono_gc_collect(mono_gc_max_generation()); + finalizing_scripts_domain = true; mono_domain_finalize(scripts_domain, 2000); finalizing_scripts_domain = false; + mono_gc_collect(mono_gc_max_generation()); + _domain_assemblies_cleanup(mono_domain_get_id(scripts_domain)); api_assembly = NULL;