allocate llRAW LookupHeightTable on demand and release it, saving a few 512KB of memory

avinationmerge
UbitUmarov 2015-09-07 08:06:41 +01:00
parent 3a8e76cdd1
commit abd6640453
1 changed files with 8 additions and 0 deletions

View File

@ -56,6 +56,10 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
HeightmapLookupValue[] LookupHeightTable; HeightmapLookupValue[] LookupHeightTable;
public LLRAW() public LLRAW()
{
}
private void BuildLookupHeightTable()
{ {
LookupHeightTable = new HeightmapLookupValue[256 * 256]; LookupHeightTable = new HeightmapLookupValue[256 * 256];
@ -186,6 +190,9 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
public void SaveStream(Stream s, ITerrainChannel map) public void SaveStream(Stream s, ITerrainChannel map)
{ {
if (LookupHeightTable == null)
BuildLookupHeightTable();
using (BinaryWriter binStream = new BinaryWriter(s)) using (BinaryWriter binStream = new BinaryWriter(s))
{ {
// Output the calculated raw // Output the calculated raw
@ -241,6 +248,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
} }
} }
} }
LookupHeightTable = null;
} }
public string FileExtension public string FileExtension