diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 95d69a1570..4776beda97 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1107,6 +1107,11 @@ namespace OpenSim.Region.Framework.Scenes } if (loginsdisabled && (m_frame > 20)) { + // 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(); + m_log.Debug("[REGION]: Enabling Logins"); loginsdisabled = false; } diff --git a/OpenSim/Region/Physics/Meshing/Mesh.cs b/OpenSim/Region/Physics/Meshing/Mesh.cs index 4c3cf33feb..e8a3e19081 100644 --- a/OpenSim/Region/Physics/Meshing/Mesh.cs +++ b/OpenSim/Region/Physics/Meshing/Mesh.cs @@ -174,6 +174,9 @@ namespace OpenSim.Region.Physics.Meshing float[] result = getVertexListAsFloat(); m_pinnedVertexes = GCHandle.Alloc(result, GCHandleType.Pinned); + // Inform the garbage collector of this unmanaged allocation so it can schedule + // the next GC round more intelligently + GC.AddMemoryPressure(Buffer.ByteLength(result)); return result; } @@ -223,6 +226,9 @@ namespace OpenSim.Region.Physics.Meshing int[] result = getIndexListAsInt(); m_pinnedIndex = GCHandle.Alloc(result, GCHandleType.Pinned); + // Inform the garbage collector of this unmanaged allocation so it can schedule + // the next GC round more intelligently + GC.AddMemoryPressure(Buffer.ByteLength(result)); return result; }