Added calls to GC.AddMemoryPressure() when unmanaged memory is allocated for ODE (helps the GC make better scheduling choices), and a call to GC.Collect() right before logins are enabled for a region. Although this doesn't change actual memory usage, it improves the reported usage from OpenSim and the operating system

0.6.8-post-fixes
John Hurliman 2009-10-26 15:52:59 -07:00
parent 428bd7a74b
commit 119cf80e13
2 changed files with 11 additions and 0 deletions

View File

@ -1107,6 +1107,11 @@ namespace OpenSim.Region.Framework.Scenes
} }
if (loginsdisabled && (m_frame > 20)) 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"); m_log.Debug("[REGION]: Enabling Logins");
loginsdisabled = false; loginsdisabled = false;
} }

View File

@ -174,6 +174,9 @@ namespace OpenSim.Region.Physics.Meshing
float[] result = getVertexListAsFloat(); float[] result = getVertexListAsFloat();
m_pinnedVertexes = GCHandle.Alloc(result, GCHandleType.Pinned); 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; return result;
} }
@ -223,6 +226,9 @@ namespace OpenSim.Region.Physics.Meshing
int[] result = getIndexListAsInt(); int[] result = getIndexListAsInt();
m_pinnedIndex = GCHandle.Alloc(result, GCHandleType.Pinned); 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; return result;
} }