Maybe slightly reduce warp3d memory leakage by disposing of decoded bitmap in Warp3DImageModule.GetTexture()

However, this still appears to be leaking massively, at least for me.  Possible cause is warp3D using GDI objects internally and not disposing of them.
0.8.0.3
Justin Clark-Casey (justincc) 2014-02-28 00:15:20 +00:00
parent 88b1fc1382
commit 5038a59ef3
1 changed files with 6 additions and 8 deletions

View File

@ -189,6 +189,7 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
} }
WarpRenderer renderer = new WarpRenderer(); WarpRenderer renderer = new WarpRenderer();
renderer.CreateScene(width, height); renderer.CreateScene(width, height);
renderer.Scene.autoCalcNormals = false; renderer.Scene.autoCalcNormals = false;
@ -243,9 +244,11 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
obj.vertexData = null; obj.vertexData = null;
obj.triangleData = null; obj.triangleData = null;
} }
renderer.Scene.removeAllObjects(); renderer.Scene.removeAllObjects();
renderer = null; renderer = null;
viewport = null; viewport = null;
m_colors.Clear(); m_colors.Clear();
GC.Collect(); GC.Collect();
m_log.Debug("[WARP 3D IMAGE MODULE]: GC.Collect()"); m_log.Debug("[WARP 3D IMAGE MODULE]: GC.Collect()");
@ -637,21 +640,16 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
if (asset != null) if (asset != null)
{ {
IJ2KDecoder imgDecoder = m_scene.RequestModuleInterface<IJ2KDecoder>(); IJ2KDecoder imgDecoder = m_scene.RequestModuleInterface<IJ2KDecoder>();
Bitmap img = null;
try try
{ {
img = (Bitmap)imgDecoder.DecodeToImage(asset); using (Bitmap img = (Bitmap)imgDecoder.DecodeToImage(asset))
ret = new warp_Texture(img);
} }
catch (Exception e) catch (Exception e)
{ {
m_log.Warn(string.Format("[WARP 3D IMAGE MODULE]: Failed to decode asset {0}, exception ", id), e); m_log.Warn(string.Format("[WARP 3D IMAGE MODULE]: Failed to decode asset {0}, exception ", id), e);
} }
if (img != null)
{
return new warp_Texture(img);
}
} }
return ret; return ret;