From 7cf2e812233d767b5a3573b74792aa28d6d91988 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 29 Dec 2016 00:47:02 +0000 Subject: [PATCH] reinforce gc.collect on region load to also do pending finalizers --- OpenSim/Region/Framework/Scenes/Scene.cs | 11 +++++------ .../Scripting/RegionReadyModule/RegionReadyModule.cs | 4 ++++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index e44f11a54e..d7a4ca46aa 100755 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1581,6 +1581,8 @@ namespace OpenSim.Region.Framework.Scenes m_heartbeatThread = null; } + GC.Collect(); + GC.WaitForPendingFinalizers(); GC.Collect(); // tell physics to finish building actor m_sceneGraph.ProcessPhysicsPreSimulation(); @@ -1856,13 +1858,9 @@ namespace OpenSim.Region.Framework.Scenes if (!LoginsEnabled && Frame == 20) { - // m_log.DebugFormat("{0} {1} {2}", LoginsDisabled, m_sceneGraph.GetActiveScriptsCount(), LoginLock); - - // In 99.9% of cases it is a bad idea to manually force garbage collection. However, - // this is a rare case where we know we have just went through a long cycle of heap - // allocations, and there is no more work to be done until someone logs in GC.Collect(); - + GC.WaitForPendingFinalizers(); + GC.Collect(); if (!LoginLock) { if (!StartDisabled) @@ -1887,6 +1885,7 @@ namespace OpenSim.Region.Framework.Scenes // LoginLock can currently only be set by a region module implementation. // If somehow this hasn't been done then the quickest way to bugfix is to see the // NullReferenceException + IRegionReadyModule rrm = RequestModuleInterface(); rrm.TriggerRegionReady(this); } diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs index 870c0bbce9..1725eb4f0c 100644 --- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs @@ -214,6 +214,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue; m_scene.LoginLock = false; + GC.Collect(); + GC.WaitForPendingFinalizers(); + GC.Collect(); + if (!m_scene.StartDisabled) { m_scene.LoginsEnabled = true;