Quantcast
Channel: Community | MonoGame - Latest topics
Viewing all articles
Browse latest Browse all 6821

Memory Allocation for SetVertexBuffer is filling up Garbage Collector

$
0
0

@kosmonautgames wrote:

Hi guys,

by far my most memory allocations which are happening on the fly and filling up garbage are SetVertexBuffers calls for instanced models. If I disable this part of rendering my GC memory doesn't fill up even half as fast.


Now is there anything I can do about that? I only call SetVertexBuffers once per frame, I only use it for smoke geometry right now.

Normal SetVertexBuffer doesn't seem to generate any garbage in comparison, and the files i am sending for the geometry instancing are:

graphicsDevice.SetVertexBuffers(vbModelBinding,
instanceBinding
);

The vbModelBinding is a vertexBufferBinding to the model, which is just set up once.

The instanceBinding is a binding like this

instanceBinding = new VertexBufferBinding(instanceVertexBuffer, 0, 1);

I don't change it per frame in terms of size, but I do change the instanceVertexBuffer per frame in terms of content.
Like this:

instanceVertexBuffer.SetData(instanceTransforms, 0, instanceTransforms.Length, SetDataOptions.Discard);

Now this is just a single Matrix per instance, so it's really not that much data I am sending.

I had no problems with memory when I sent every piece of geometry individually (via SetVertexBuffer, Indices) 300 times, but performance on GPU-side is a lot better with sending 1 piece of geometry and 300 transformation matrices, however GC hates it.

What to do?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 6821