[MDX] Vertex and C# allocation

Started by
3 comments, last by remigius 17 years, 12 months ago
Ok, I am being a bit paranoid here. I am creating an array of CustomVertex.TransformedColoredTextured. But, I need to drop the array and re-create a new one of different size... so: call 1: myvert = new Microsoft.DirectX.Direct3D.CustomVertex.TransformedColoredTextured[10]; call 2: myvert = new Microsoft.DirectX.Direct3D.CustomVertex.TransformedColoredTextured[22]; There is no "Dispose" function inside the CustomVertex. So does the memory from the first step that allocated 10 objects get released? I am hoping it does, but I am unsure how it plays out with MDX. Thank you.
Advertisement
As you create a normal managed array and not a MDX vertex buffer there is no need to dispose it. The garbage collector will detected that there is no reference left and will free the memory for future use.
A quick semi-related question here... So arrays will be handled by the GC as I thought, but what about a single struct? I was under the impression that these get handled by 'deterministic finalization', ie. once the app leaves execution block in which they were created, they automagically are freed (provided they're not referenced elsewhere). Would that be correct, or are structs also just freed by the GC?
Rim van Wersch [ MDXInfo ] [ XNAInfo ] [ YouTube ] - Do yourself a favor and bookmark this excellent free online D3D/shader book!
Thanks for the reply.

Regarding the struct, here is a great article that will explain it very well.
http://www.albahari.com/value%20vs%20reference%20types.html
And thanks for the article, a very interesting read!
Rim van Wersch [ MDXInfo ] [ XNAInfo ] [ YouTube ] - Do yourself a favor and bookmark this excellent free online D3D/shader book!

This topic is closed to new replies.

Advertisement