From 96734fe4c5131ad2b27041ea3a17834e5a45b0b2 Mon Sep 17 00:00:00 2001 From: Kernell Date: Fri, 13 Mar 2015 13:14:45 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D0=B1=D0=B0=D0=B3=20=D1=81=20=D0=BA=D1=80=D0=B0?= =?UTF-8?q?=D1=88=D0=B5=D0=BC=20=D1=81=D0=B5=D1=80=D0=B2=D0=B5=D1=80=D0=B0?= =?UTF-8?q?=20=D0=BF=D1=80=D0=B8=20=D0=BF=D0=BE=D0=B2=D1=82=D0=BE=D1=80?= =?UTF-8?q?=D0=BD=D0=BE=D0=BC=20=D0=B7=D0=B0=D0=BF=D1=83=D1=81=D0=BA=D0=B5?= =?UTF-8?q?=20=D1=80=D0=B5=D1=81=D1=83=D1=80=D1=81=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mta-mono/src/CResource.cpp | 21 +++++++++++++++------ mta-mono/src/CResourceManager.h | 2 +- mta-mono/src/Common.h | 2 ++ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/mta-mono/src/CResource.cpp b/mta-mono/src/CResource.cpp index 7eeaf96..6f59605 100644 --- a/mta-mono/src/CResource.cpp +++ b/mta-mono/src/CResource.cpp @@ -34,17 +34,26 @@ CResource::CResource( lua_State *pLuaVM, string sName ) CResource::~CResource( void ) { - if( this->m_pMonoGCHandle ) - { - mono_gchandle_free( this->m_pMonoGCHandle ); - } + mono_domain_set( mono_get_root_domain(), false ); if( this->m_pMonoDomain ) { mono_domain_unload( this->m_pMonoDomain ); } + mono_gc_collect( mono_gc_max_generation() ); + g_pResourceManager->RemoveFromList( this ); + + this->m_pMonoAssembly = NULL; + this->m_pMonoAssemblyLib = NULL; + this->m_pMonoGCHandle = NULL; + this->m_pMonoDomain = NULL; + this->m_pMonoImage = NULL; + this->m_pMonoImageLib = NULL; + this->m_pMonoClass = NULL; + + this->m_pLuaVM = NULL; } bool CResource::Init( void ) @@ -56,7 +65,7 @@ bool CResource::Init( void ) string sNamespace ( this->m_sName ); string sClass ( "Program" ); - this->m_pMonoDomain = mono_domain_create_appdomain( const_cast< char* >( this->m_sName.c_str() ), NULL ); + this->m_pMonoDomain = mono_domain_create_appdomain( const_cast< char* >( this->m_sName.c_str( ) ), NULL ); if( !this->m_pMonoDomain ) { @@ -88,7 +97,7 @@ bool CResource::Init( void ) MonoObject *pMonoObject = mono_object_new( this->m_pMonoDomain, this->m_pMonoClass ); - this->m_pMonoGCHandle = mono_gchandle_new( pMonoObject, true ); + mono_gchandle_new( pMonoObject, false ); mono_runtime_object_init( pMonoObject ); diff --git a/mta-mono/src/CResourceManager.h b/mta-mono/src/CResourceManager.h index 105f370..bfd9955 100644 --- a/mta-mono/src/CResourceManager.h +++ b/mta-mono/src/CResourceManager.h @@ -35,7 +35,7 @@ public: // mono_config_parse( NULL ); - mono_debug_init( MONO_DEBUG_FORMAT_MONO ); + // mono_debug_init( MONO_DEBUG_FORMAT_MONO ); this->m_pMonoDomain = mono_jit_init_version( "Mono Root", "v4.0.30319" ); diff --git a/mta-mono/src/Common.h b/mta-mono/src/Common.h index e7a4021..a9e8833 100644 --- a/mta-mono/src/Common.h +++ b/mta-mono/src/Common.h @@ -46,6 +46,8 @@ extern "C" #include #include #include +#include +#include #include "include/ILuaModuleManager.h"