Dispose of graphics resources deterministically.
Textures, FrameBuffers and VertexBuffers allocated by the Sdl2 Renderer were only being released via finalizers. This could lead to OpenGL out of memory errors since resources may not be cleaned up in a timely manner. To avoid this, IDisposable has been implemented and transitively applied to classes that use these resources. As a side-effect some static state is no longer static, particularly in Renderer, in order to facilitate this change and just for nicer design in general. Also dispose some bitmaps.
This commit is contained in:
committed by
RoosterDragon
parent
38b579a081
commit
f0f02dff5c
@@ -8,11 +8,12 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Graphics
|
||||
{
|
||||
class TerrainRenderer
|
||||
sealed class TerrainRenderer : IDisposable
|
||||
{
|
||||
IVertexBuffer<Vertex> vertexBuffer;
|
||||
|
||||
@@ -58,5 +59,10 @@ namespace OpenRA.Graphics
|
||||
foreach (var r in world.WorldActor.TraitsImplementing<IRenderOverlay>())
|
||||
r.Render(wr);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
vertexBuffer.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user