Skip to content

StructuredBuffer failing to release unmanaged resources, leading to memory leak #8

@scatterlogical

Description

@scatterlogical

Prerequisites

  • I have verified this issue is present in the develop branch
  • I have searched open and closed issues to ensure it has not already been reported.

MonoGame Version

MonoGame.Framework.Compute.WindowsDX 3.8.3

Which MonoGame platform are you using?

MonoGame Windows Desktop Application (mgwindowsdx)

Operating System

Windows

Description

StructuredBuffers don't seem to release unmanaged resources when disposed, leading to massive memory leakage in unmanaged memory.

Steps to Reproduce

Using the indirect_draw_instances compute example, I changed the Draw() method as such:

`protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.Black);

        particleBuffer1 = new StructuredBuffer(GraphicsDevice, typeof(Particle), MaxParticleCount, BufferUsage.None, ShaderAccess.ReadWrite); //added
        particleBuffer2 = new StructuredBuffer(GraphicsDevice, typeof(Particle), MaxParticleCount, BufferUsage.None, ShaderAccess.ReadWrite); //added

        ComputeParticles(gameTime);

        DrawParticles();
        DrawText();
        DrawMousePointer();

        particleBuffer1.Dispose(); //added
        particleBuffer2.Dispose(); //added

        base.Draw(gameTime);   
    }`

Minimal Example Repo

No response

Expected Behavior

The unmanaged resources should be released when disposed is called, freeing unmanaged memory.

Resulting Behavior

Image

Files

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions