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();
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -318,8 +321,17 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
|
|||
uint globalX, 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 = new warp_Texture(image);
|
||||
warp_Texture texture;
|
||||
|
||||
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);
|
||||
material.setReflectivity(50);
|
||||
renderer.Scene.addMaterial("TerrainColor", material);
|
||||
|
@ -546,12 +558,15 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
|
|||
{
|
||||
try
|
||||
{
|
||||
Bitmap bitmap = (Bitmap)J2kImage.FromStream(stream);
|
||||
int pixelBytes;
|
||||
|
||||
using (Bitmap bitmap = (Bitmap)J2kImage.FromStream(stream))
|
||||
{
|
||||
width = bitmap.Width;
|
||||
height = bitmap.Height;
|
||||
|
||||
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
|
||||
unsafe
|
||||
|
@ -586,6 +601,7 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get the averages for each channel
|
||||
const decimal OO_255 = 1m / 255m;
|
||||
|
|
|
@ -84,7 +84,11 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
|
|||
Debug.Assert(heightRanges.Length == 4);
|
||||
|
||||
Bitmap[] detailTexture = new Bitmap[4];
|
||||
Bitmap output = null;
|
||||
BitmapData outputData = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (textureTerrain)
|
||||
{
|
||||
// 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
|
||||
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
|
||||
byte[] data;
|
||||
|
@ -241,8 +250,8 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
|
|||
|
||||
#region Texture Compositing
|
||||
|
||||
Bitmap output = new Bitmap(256, 256, PixelFormat.Format24bppRgb);
|
||||
BitmapData outputData = output.LockBits(new Rectangle(0, 0, 256, 256), ImageLockMode.WriteOnly, PixelFormat.Format24bppRgb);
|
||||
output = new Bitmap(256, 256, PixelFormat.Format24bppRgb);
|
||||
outputData = output.LockBits(new Rectangle(0, 0, 256, 256), ImageLockMode.WriteOnly, PixelFormat.Format24bppRgb);
|
||||
|
||||
unsafe
|
||||
{
|
||||
|
@ -297,6 +306,13 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
|
|||
for (int i = 0; i < 4; i++)
|
||||
detailTexture[i].UnlockBits(datas[i]);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
if (detailTexture[i] != null)
|
||||
detailTexture[i].Dispose();
|
||||
}
|
||||
|
||||
output.UnlockBits(outputData);
|
||||
|
||||
|
|
|
@ -1343,14 +1343,14 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
|||
if (terrain == null)
|
||||
return;
|
||||
|
||||
m_log.DebugFormat("[WORLDMAP]: Generating map image for {0}", m_scene.RegionInfo.RegionName);
|
||||
|
||||
byte[] data = terrain.WriteJpeg2000Image();
|
||||
if (data == null)
|
||||
return;
|
||||
|
||||
byte[] overlay = GenerateOverlay();
|
||||
|
||||
m_log.Debug("[WORLDMAP]: STORING MAPTILE IMAGE");
|
||||
|
||||
UUID terrainImageID = UUID.Random();
|
||||
UUID parcelImageID = UUID.Zero;
|
||||
|
||||
|
@ -1365,7 +1365,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
|||
asset.Flags = AssetFlags.Maptile;
|
||||
|
||||
// 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);
|
||||
|
||||
if (overlay != null)
|
||||
|
|
Loading…
Reference in New Issue