aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-02-15 01:45:25 +0000
committerJustin Clark-Casey (justincc)2012-02-15 01:45:25 +0000
commitebe5e1731d24e68ec7a8aa61a397f5febc1c2662 (patch)
treee735ca22a967b6fc82e36678042dbc53db5bfee9 /OpenSim
parentFix: get embedded objects from Notecard fails with activated FreeSwitchVoiceM... (diff)
downloadopensim-SC_OLD-ebe5e1731d24e68ec7a8aa61a397f5febc1c2662.zip
opensim-SC_OLD-ebe5e1731d24e68ec7a8aa61a397f5febc1c2662.tar.gz
opensim-SC_OLD-ebe5e1731d24e68ec7a8aa61a397f5febc1c2662.tar.bz2
opensim-SC_OLD-ebe5e1731d24e68ec7a8aa61a397f5febc1c2662.tar.xz
In ObjectTortureTests, run garbage collector on Teardown and run scene loop update when scene objects have been deleted.
At least on mono 2.6.4, running GC.Collect() is not guaranteed to force gc of all objects when run in the same method where those objects had references. Therefore, GC.Collect() is now being done in the per-script teardown of ObjectTortureTests. In addition, scene loop update is being run after garbage collection in order to clean out the viewer update list of scene objects in the SceneGraph. These measures mean that scene objects/parts are now garbage collected after a test run if deleted from the scene, resulting in a much better memory usage report (though probably still not very accurate). However, deletion takes a very long time - what's really needed is to find out now why the entire scene isn't being GC'd by this measure. This change hasn't yet been applied to the other stress tests.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs10
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs41
-rw-r--r--OpenSim/Tests/Common/Mock/TestScene.cs3
-rw-r--r--OpenSim/Tests/Torture/ObjectTortureTests.cs21
5 files changed, 68 insertions, 10 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 693a79e..e66678a 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -359,7 +359,7 @@ namespace OpenSim.Region.Framework.Scenes
359 m_log.ErrorFormat( 359 m_log.ErrorFormat(
360 "[SCENEGRAPH]: Tried to add scene object {0} to {1} with illegal UUID of {2}", 360 "[SCENEGRAPH]: Tried to add scene object {0} to {1} with illegal UUID of {2}",
361 sceneObject.Name, m_parentScene.RegionInfo.RegionName, UUID.Zero); 361 sceneObject.Name, m_parentScene.RegionInfo.RegionName, UUID.Zero);
362 362
363 return false; 363 return false;
364 } 364 }
365 365
@@ -368,12 +368,12 @@ namespace OpenSim.Region.Framework.Scenes
368// m_log.DebugFormat( 368// m_log.DebugFormat(
369// "[SCENEGRAPH]: Scene graph for {0} already contains object {1} in AddSceneObject()", 369// "[SCENEGRAPH]: Scene graph for {0} already contains object {1} in AddSceneObject()",
370// m_parentScene.RegionInfo.RegionName, sceneObject.UUID); 370// m_parentScene.RegionInfo.RegionName, sceneObject.UUID);
371 371
372 return false; 372 return false;
373 } 373 }
374 374
375// m_log.DebugFormat( 375// m_log.DebugFormat(
376// "[SCENEGRAPH]: Adding scene object {0} {1}, with {2} parts on {3}", 376// "[SCENEGRAPH]: Adding scene object {0} {1}, with {2} parts on {3}",
377// sceneObject.Name, sceneObject.UUID, sceneObject.Parts.Length, m_parentScene.RegionInfo.RegionName); 377// sceneObject.Name, sceneObject.UUID, sceneObject.Parts.Length, m_parentScene.RegionInfo.RegionName);
378 378
379 SceneObjectPart[] parts = sceneObject.Parts; 379 SceneObjectPart[] parts = sceneObject.Parts;
@@ -409,7 +409,7 @@ namespace OpenSim.Region.Framework.Scenes
409 409
410 lock (SceneObjectGroupsByFullID) 410 lock (SceneObjectGroupsByFullID)
411 SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject; 411 SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject;
412 412
413 lock (SceneObjectGroupsByFullPartID) 413 lock (SceneObjectGroupsByFullPartID)
414 { 414 {
415 foreach (SceneObjectPart part in parts) 415 foreach (SceneObjectPart part in parts)
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 4c339d9..b130bf7 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -303,6 +303,9 @@ namespace OpenSim.Region.Framework.Scenes
303 303
304// ~SceneObjectPart() 304// ~SceneObjectPart()
305// { 305// {
306// Console.WriteLine(
307// "[SCENE OBJECT PART]: Destructor called for {0}, local id {1}, parent {2} {3}",
308// Name, LocalId, ParentGroup.Name, ParentGroup.LocalId);
306// m_log.DebugFormat( 309// m_log.DebugFormat(
307// "[SCENE OBJECT PART]: Destructor called for {0}, local id {1}, parent {2} {3}", 310// "[SCENE OBJECT PART]: Destructor called for {0}, local id {1}, parent {2} {3}",
308// Name, LocalId, ParentGroup.Name, ParentGroup.LocalId); 311// Name, LocalId, ParentGroup.Name, ParentGroup.LocalId);
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
index 80f198d..7737d8e 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Reflection; 29using System.Reflection;
30using System.Threading;
30using NUnit.Framework; 31using NUnit.Framework;
31using OpenMetaverse; 32using OpenMetaverse;
32using OpenSim.Framework; 33using OpenSim.Framework;
@@ -43,6 +44,42 @@ namespace OpenSim.Region.Framework.Scenes.Tests
43 [TestFixture] 44 [TestFixture]
44 public class SceneObjectBasicTests 45 public class SceneObjectBasicTests
45 { 46 {
47// [TearDown]
48// public void TearDown()
49// {
50// Console.WriteLine("TearDown");
51// GC.Collect();
52// Thread.Sleep(3000);
53// }
54
55// public class GcNotify
56// {
57// public static AutoResetEvent gcEvent = new AutoResetEvent(false);
58// private static bool _initialized = false;
59//
60// public static void Initialize()
61// {
62// if (!_initialized)
63// {
64// _initialized = true;
65// new GcNotify();
66// }
67// }
68//
69// private GcNotify(){}
70//
71// ~GcNotify()
72// {
73// if (!Environment.HasShutdownStarted &&
74// !AppDomain.CurrentDomain.IsFinalizingForUnload())
75// {
76// Console.WriteLine("GcNotify called");
77// gcEvent.Set();
78// new GcNotify();
79// }
80// }
81// }
82
46 /// <summary> 83 /// <summary>
47 /// Test adding an object to a scene. 84 /// Test adding an object to a scene.
48 /// </summary> 85 /// </summary>
@@ -147,11 +184,11 @@ namespace OpenSim.Region.Framework.Scenes.Tests
147 public void TestDeleteSceneObject() 184 public void TestDeleteSceneObject()
148 { 185 {
149 TestHelpers.InMethod(); 186 TestHelpers.InMethod();
150 187
151 TestScene scene = SceneHelpers.SetupScene(); 188 TestScene scene = SceneHelpers.SetupScene();
152 SceneObjectPart part = SceneHelpers.AddSceneObject(scene); 189 SceneObjectPart part = SceneHelpers.AddSceneObject(scene);
153 scene.DeleteSceneObject(part.ParentGroup, false); 190 scene.DeleteSceneObject(part.ParentGroup, false);
154 191
155 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); 192 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
156 Assert.That(retrievedPart, Is.Null); 193 Assert.That(retrievedPart, Is.Null);
157 } 194 }
diff --git a/OpenSim/Tests/Common/Mock/TestScene.cs b/OpenSim/Tests/Common/Mock/TestScene.cs
index 328cd2b..eea68c3 100644
--- a/OpenSim/Tests/Common/Mock/TestScene.cs
+++ b/OpenSim/Tests/Common/Mock/TestScene.cs
@@ -50,7 +50,8 @@ namespace OpenSim.Tests.Common.Mock
50 50
51 ~TestScene() 51 ~TestScene()
52 { 52 {
53 Console.WriteLine("TestScene destructor called for {0}", RegionInfo.RegionName); 53 //Console.WriteLine("TestScene destructor called for {0}", RegionInfo.RegionName);
54 Console.WriteLine("TestScene destructor called");
54 } 55 }
55 56
56 /// <summary> 57 /// <summary>
diff --git a/OpenSim/Tests/Torture/ObjectTortureTests.cs b/OpenSim/Tests/Torture/ObjectTortureTests.cs
index 74b336e..e83186a 100644
--- a/OpenSim/Tests/Torture/ObjectTortureTests.cs
+++ b/OpenSim/Tests/Torture/ObjectTortureTests.cs
@@ -49,6 +49,13 @@ namespace OpenSim.Tests.Torture
49 [TestFixture] 49 [TestFixture]
50 public class ObjectTortureTests 50 public class ObjectTortureTests
51 { 51 {
52 [TearDown]
53 public void TearDown()
54 {
55 GC.Collect();
56 GC.WaitForPendingFinalizers();
57 }
58
52// [Test] 59// [Test]
53// public void Test0000Clean() 60// public void Test0000Clean()
54// { 61// {
@@ -141,8 +148,18 @@ namespace OpenSim.Tests.Torture
141 string.Format("Object {0} could not be retrieved", i)); 148 string.Format("Object {0} could not be retrieved", i));
142 } 149 }
143 150
144 // This does not work to fire the SceneObjectGroup destructors - something else is hanging on to them. 151 // When a scene object is added to a scene, it is placed in the update list for sending to viewers
145// scene.DeleteAllSceneObjects(); 152 // (though in this case we have none). When it is deleted, it is not removed from the update which is
153 // fine since it will later be ignored.
154 //
155 // However, that means that we need to manually run an update here to clear out that list so that deleted
156 // objects will be clean up by the garbage collector before the next stress test is run.
157 scene.Update();
158
159 // Currently, we need to do this in order to garbage collect the scene objects ready for the next test run.
160 // However, what we really need to do is find out why the entire scene is not garbage collected in
161 // teardown.
162 scene.DeleteAllSceneObjects();
146 163
147 Console.WriteLine( 164 Console.WriteLine(
148 "Took {0}ms, {1}MB ({2} - {3}) to create {4} objects each containing {5} prim(s)", 165 "Took {0}ms, {1}MB ({2} - {3}) to create {4} objects each containing {5} prim(s)",