diff --git a/OpenSim/Framework/Servers/HttpServer/Interfaces/IOSHttpResponse.cs b/OpenSim/Framework/Servers/HttpServer/Interfaces/IOSHttpResponse.cs index d26b68a7fb..aba15b019c 100644 --- a/OpenSim/Framework/Servers/HttpServer/Interfaces/IOSHttpResponse.cs +++ b/OpenSim/Framework/Servers/HttpServer/Interfaces/IOSHttpResponse.cs @@ -118,8 +118,6 @@ namespace OpenSim.Framework.Servers.HttpServer /// string StatusDescription { get; set; } -// bool ReuseContext { get; set; } - /// /// Add a header field and content to the response. /// diff --git a/OpenSim/Framework/Servers/ServerBase.cs b/OpenSim/Framework/Servers/ServerBase.cs index 3c2dce81c8..ff3c80d970 100644 --- a/OpenSim/Framework/Servers/ServerBase.cs +++ b/OpenSim/Framework/Servers/ServerBase.cs @@ -31,6 +31,7 @@ using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; +using System.Runtime; using System.Text; using System.Text.RegularExpressions; using System.Threading; @@ -508,7 +509,11 @@ namespace OpenSim.Framework.Servers private void HandleForceGc(string module, string[] args) { Notice("Manually invoking runtime garbage collection"); + GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce; GC.Collect(); + GC.WaitForPendingFinalizers(); + GC.Collect(); + GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.Default; } public virtual void HandleShow(string module, string[] cmd) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index bd178c07bc..516c1e51cc 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -30,6 +30,7 @@ using System.Collections; using System.Collections.Generic; using System.Net; using System.Reflection; +using System.Runtime; using System.Text; using System.Threading; using System.Timers; @@ -635,9 +636,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP if(m_scene.GetNumberOfClients() == 0) { + GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce; GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); + GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.Default; } } diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs index 11c53d75d0..fe74cf1a88 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs @@ -30,6 +30,7 @@ using System.Collections.Generic; using System.IO; using System.IO.Compression; using System.Reflection; +using System.Runtime; using System.Text.RegularExpressions; using System.Threading; using System.Xml; @@ -216,6 +217,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver CloseArchive(e.Message); throw; } + + GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce; + GC.Collect(); + GC.WaitForPendingFinalizers(); + GC.Collect(); + GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.Default; } private void ArchiveOneRegion(Scene scene, string regionDir, Dictionary assetUuids, @@ -282,6 +289,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver assetGatherer.GatherAll(); + GC.Collect(); int errors = assetGatherer.FailedUUIDs.Count; m_log.DebugFormat( "[ARCHIVER]: {0} region scene objects to save reference {1} possible assets", @@ -313,6 +321,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver assetUuids[regionSettings.TerrainTexture4] = (sbyte)AssetType.Texture; Save(scene, sceneObjects, regionDir); + GC.Collect(); } /// diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs index 91f4dc354f..6e810253c0 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs @@ -133,6 +133,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver m_timeOutTimer .AutoReset = false; m_timeOutTimer.Elapsed += OnTimeout; m_timeout = false; + int gccontrol = 0; foreach (KeyValuePair kvp in m_uuids) { @@ -161,6 +162,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver m_foundAssetUuids.Add(asset.FullID); m_assetsArchiver.WriteAsset(PostProcess(asset)); + if(++gccontrol > 5000) + { + gccontrol = 0; + GC.Collect(); + } } catch (Exception e) @@ -180,6 +186,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver m_log.DebugFormat("[ARCHIVER]: Successfully added {0} assets ({1} of total possible assets requested were not found, were damaged or were not assets)", m_foundAssetUuids.Count, totalerrors); + GC.Collect(); PerformAssetsRequestCallback(m_timeout); } diff --git a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs index 82cc12cf65..975184ac75 100644 --- a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs +++ b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs @@ -31,6 +31,7 @@ using System.Drawing; using System.Drawing.Imaging; using System.IO; using System.Reflection; +using System.Runtime; using CSJ2K; using Nini.Config; @@ -261,8 +262,11 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap m_colors.Clear(); m_warpTextures.Clear(); + GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce; GC.Collect(); -// m_log.Debug("[WARP 3D IMAGE MODULE]: GC.Collect()"); + GC.WaitForPendingFinalizers(); + GC.Collect(); + GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.Default; return bitmap; } diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs index a1dd711814..732735e6e9 100644 --- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs @@ -28,6 +28,7 @@ using System; using System.Collections.Generic; using System.Reflection; +using System.Runtime; using System.Net; using System.IO; using System.Text; @@ -214,9 +215,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue; m_scene.LoginLock = false; + GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce; GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); + GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.Default; if (!m_scene.StartDisabled) { diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index d0043ba7d9..b020215f0f 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs @@ -204,8 +204,7 @@ namespace OpenSim.Server.Base xw.Flush(); ms.Seek(0, SeekOrigin.Begin); - byte[] ret = ms.GetBuffer(); - Array.Resize(ref ret, (int)ms.Length); + byte[] ret = ms.ToArray(); return ret; } @@ -579,9 +578,12 @@ namespace OpenSim.Server.Base // Try to read it try { - XmlReader r = XmlReader.Create(url); - IConfigSource cs = new XmlConfigSource(r); - source.Merge(cs); + IConfigSource cs; + using( XmlReader r = XmlReader.Create(url)) + { + cs = new XmlConfigSource(r); + source.Merge(cs); + } } catch (Exception e) {