From c87751a822db328145963782f0f10adb23e32d39 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 7 Feb 2012 23:03:53 +0000
Subject: Add start GC memory and end GC memory to object stress test
 printouts.

This illustrates that references to Scene, SOG, etc. are not currently being released when a stress test ends (or at regression test end in general).
This means even the current stress tests take much more memory than they need, a problem that will have to be addressed.
---
 OpenSim/Tests/Common/Mock/TestScene.cs      |  5 +++++
 OpenSim/Tests/Torture/ObjectTortureTests.cs | 16 +++++++++++++---
 OpenSim/Tests/Torture/ScriptTortureTests.cs |  2 ++
 3 files changed, 20 insertions(+), 3 deletions(-)

(limited to 'OpenSim/Tests')

diff --git a/OpenSim/Tests/Common/Mock/TestScene.cs b/OpenSim/Tests/Common/Mock/TestScene.cs
index 07bcdce..328cd2b 100644
--- a/OpenSim/Tests/Common/Mock/TestScene.cs
+++ b/OpenSim/Tests/Common/Mock/TestScene.cs
@@ -47,6 +47,11 @@ namespace OpenSim.Tests.Common.Mock
                    dumpAssetsToFile, config, simulatorVersion)
         {
         }
+
+        ~TestScene()
+        {
+            Console.WriteLine("TestScene destructor called for {0}", RegionInfo.RegionName);
+        }
         
         /// <summary>
         /// Temporarily override session authentication for tests (namely teleport).
diff --git a/OpenSim/Tests/Torture/ObjectTortureTests.cs b/OpenSim/Tests/Torture/ObjectTortureTests.cs
index 444b7ec..74b336e 100644
--- a/OpenSim/Tests/Torture/ObjectTortureTests.cs
+++ b/OpenSim/Tests/Torture/ObjectTortureTests.cs
@@ -131,7 +131,7 @@ namespace OpenSim.Tests.Torture
 
             TimeSpan elapsed = DateTime.Now - start;
 //            long processMemoryAlloc = process.PrivateMemorySize64 - startProcessMemory;
-            long processGcAlloc = GC.GetTotalMemory(false) - startGcMemory;
+            long endGcMemory = GC.GetTotalMemory(false);
 
             for (int i = 1; i <= objectsToAdd; i++)
             {
@@ -141,9 +141,19 @@ namespace OpenSim.Tests.Torture
                     string.Format("Object {0} could not be retrieved", i));
             }
 
+            // This does not work to fire the SceneObjectGroup destructors - something else is hanging on to them.
+//            scene.DeleteAllSceneObjects();
+
             Console.WriteLine(
-                "Took {0}ms, {1}MB to create {2} objects each containing {3} prim(s)",
-                Math.Round(elapsed.TotalMilliseconds), processGcAlloc / 1024 / 1024, objectsToAdd, primsInEachObject);
+                "Took {0}ms, {1}MB ({2} - {3}) to create {4} objects each containing {5} prim(s)",
+                Math.Round(elapsed.TotalMilliseconds),
+                (endGcMemory - startGcMemory) / 1024 / 1024,
+                endGcMemory / 1024 / 1024,
+                startGcMemory / 1024 / 1024,
+                objectsToAdd,
+                primsInEachObject);
+
+            scene = null;
         }
     }
 }
\ No newline at end of file
diff --git a/OpenSim/Tests/Torture/ScriptTortureTests.cs b/OpenSim/Tests/Torture/ScriptTortureTests.cs
index c0239ba..d94bbde 100644
--- a/OpenSim/Tests/Torture/ScriptTortureTests.cs
+++ b/OpenSim/Tests/Torture/ScriptTortureTests.cs
@@ -107,6 +107,8 @@ namespace OpenSim.Tests.Torture
             m_expectedChatMessages = scriptsToCreate;
             int startingObjectIdTail = 0x100;
 
+            GC.Collect();
+
             for (int idTail = startingObjectIdTail;idTail < startingObjectIdTail + scriptsToCreate; idTail++)
             {
                 AddObjectAndScript(idTail, userId);
-- 
cgit v1.1