Actively dispose of Bitmaps in Warp3D image module and world map module once we've finished with them.
This might help with memory leakage issues though I suspect it won't.0.7.4.1
parent
3b25021180
commit
2b0de66216
|
@ -204,7 +204,10 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
|
||||||
Bitmap bitmap = renderer.Scene.getImage();
|
Bitmap bitmap = renderer.Scene.getImage();
|
||||||
|
|
||||||
if (m_useAntiAliasing)
|
if (m_useAntiAliasing)
|
||||||
bitmap = ImageUtils.ResizeImage(bitmap, viewport.Width, viewport.Height);
|
{
|
||||||
|
using (Bitmap origBitmap = bitmap)
|
||||||
|
bitmap = ImageUtils.ResizeImage(origBitmap, viewport.Width, viewport.Height);
|
||||||
|
}
|
||||||
|
|
||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
|
@ -318,8 +321,17 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
|
||||||
uint globalX, globalY;
|
uint globalX, globalY;
|
||||||
Utils.LongToUInts(m_scene.RegionInfo.RegionHandle, out globalX, out globalY);
|
Utils.LongToUInts(m_scene.RegionInfo.RegionHandle, out globalX, out globalY);
|
||||||
|
|
||||||
Bitmap image = TerrainSplat.Splat(heightmap, textureIDs, startHeights, heightRanges, new Vector3d(globalX, globalY, 0.0), m_scene.AssetService, textureTerrain);
|
warp_Texture texture;
|
||||||
warp_Texture texture = new warp_Texture(image);
|
|
||||||
|
using (
|
||||||
|
Bitmap image
|
||||||
|
= TerrainSplat.Splat(
|
||||||
|
heightmap, textureIDs, startHeights, heightRanges,
|
||||||
|
new Vector3d(globalX, globalY, 0.0), m_scene.AssetService, textureTerrain))
|
||||||
|
{
|
||||||
|
texture = new warp_Texture(image);
|
||||||
|
}
|
||||||
|
|
||||||
warp_Material material = new warp_Material(texture);
|
warp_Material material = new warp_Material(texture);
|
||||||
material.setReflectivity(50);
|
material.setReflectivity(50);
|
||||||
renderer.Scene.addMaterial("TerrainColor", material);
|
renderer.Scene.addMaterial("TerrainColor", material);
|
||||||
|
@ -546,12 +558,15 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Bitmap bitmap = (Bitmap)J2kImage.FromStream(stream);
|
int pixelBytes;
|
||||||
|
|
||||||
|
using (Bitmap bitmap = (Bitmap)J2kImage.FromStream(stream))
|
||||||
|
{
|
||||||
width = bitmap.Width;
|
width = bitmap.Width;
|
||||||
height = bitmap.Height;
|
height = bitmap.Height;
|
||||||
|
|
||||||
BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadOnly, bitmap.PixelFormat);
|
BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadOnly, bitmap.PixelFormat);
|
||||||
int pixelBytes = (bitmap.PixelFormat == PixelFormat.Format24bppRgb) ? 3 : 4;
|
pixelBytes = (bitmap.PixelFormat == PixelFormat.Format24bppRgb) ? 3 : 4;
|
||||||
|
|
||||||
// Sum up the individual channels
|
// Sum up the individual channels
|
||||||
unsafe
|
unsafe
|
||||||
|
@ -586,6 +601,7 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Get the averages for each channel
|
// Get the averages for each channel
|
||||||
const decimal OO_255 = 1m / 255m;
|
const decimal OO_255 = 1m / 255m;
|
||||||
|
|
|
@ -84,7 +84,11 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
|
||||||
Debug.Assert(heightRanges.Length == 4);
|
Debug.Assert(heightRanges.Length == 4);
|
||||||
|
|
||||||
Bitmap[] detailTexture = new Bitmap[4];
|
Bitmap[] detailTexture = new Bitmap[4];
|
||||||
|
Bitmap output = null;
|
||||||
|
BitmapData outputData = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
if (textureTerrain)
|
if (textureTerrain)
|
||||||
{
|
{
|
||||||
// Swap empty terrain textureIDs with default IDs
|
// Swap empty terrain textureIDs with default IDs
|
||||||
|
@ -138,7 +142,12 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
|
||||||
|
|
||||||
// Make sure this texture is the correct size, otherwise resize
|
// Make sure this texture is the correct size, otherwise resize
|
||||||
if (bitmap.Width != 256 || bitmap.Height != 256)
|
if (bitmap.Width != 256 || bitmap.Height != 256)
|
||||||
bitmap = ImageUtils.ResizeImage(bitmap, 256, 256);
|
{
|
||||||
|
using (Bitmap origBitmap = bitmap)
|
||||||
|
{
|
||||||
|
bitmap = ImageUtils.ResizeImage(origBitmap, 256, 256);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Save the decoded and resized texture to the cache
|
// Save the decoded and resized texture to the cache
|
||||||
byte[] data;
|
byte[] data;
|
||||||
|
@ -241,8 +250,8 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
|
||||||
|
|
||||||
#region Texture Compositing
|
#region Texture Compositing
|
||||||
|
|
||||||
Bitmap output = new Bitmap(256, 256, PixelFormat.Format24bppRgb);
|
output = new Bitmap(256, 256, PixelFormat.Format24bppRgb);
|
||||||
BitmapData outputData = output.LockBits(new Rectangle(0, 0, 256, 256), ImageLockMode.WriteOnly, PixelFormat.Format24bppRgb);
|
outputData = output.LockBits(new Rectangle(0, 0, 256, 256), ImageLockMode.WriteOnly, PixelFormat.Format24bppRgb);
|
||||||
|
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
|
@ -297,6 +306,13 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
detailTexture[i].UnlockBits(datas[i]);
|
detailTexture[i].UnlockBits(datas[i]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
if (detailTexture[i] != null)
|
||||||
|
detailTexture[i].Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
output.UnlockBits(outputData);
|
output.UnlockBits(outputData);
|
||||||
|
|
||||||
|
|
|
@ -1343,14 +1343,14 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
||||||
if (terrain == null)
|
if (terrain == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
m_log.DebugFormat("[WORLDMAP]: Generating map image for {0}", m_scene.RegionInfo.RegionName);
|
||||||
|
|
||||||
byte[] data = terrain.WriteJpeg2000Image();
|
byte[] data = terrain.WriteJpeg2000Image();
|
||||||
if (data == null)
|
if (data == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
byte[] overlay = GenerateOverlay();
|
byte[] overlay = GenerateOverlay();
|
||||||
|
|
||||||
m_log.Debug("[WORLDMAP]: STORING MAPTILE IMAGE");
|
|
||||||
|
|
||||||
UUID terrainImageID = UUID.Random();
|
UUID terrainImageID = UUID.Random();
|
||||||
UUID parcelImageID = UUID.Zero;
|
UUID parcelImageID = UUID.Zero;
|
||||||
|
|
||||||
|
@ -1365,7 +1365,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
||||||
asset.Flags = AssetFlags.Maptile;
|
asset.Flags = AssetFlags.Maptile;
|
||||||
|
|
||||||
// Store the new one
|
// Store the new one
|
||||||
m_log.DebugFormat("[WORLDMAP]: Storing map tile {0}", asset.ID);
|
m_log.DebugFormat("[WORLDMAP]: Storing map tile {0} for {1}", asset.ID, m_scene.RegionInfo.RegionName);
|
||||||
|
|
||||||
m_scene.AssetService.Store(asset);
|
m_scene.AssetService.Store(asset);
|
||||||
|
|
||||||
if (overlay != null)
|
if (overlay != null)
|
||||||
|
|
Loading…
Reference in New Issue