Currently I am using XNA Game Studio 4.0 with C# Visual Studio 2010. I want to use a versatile method for handling triangles. I am using a preset array of VertexPositionColor items passed through the GraphicsDevice.DrawUserPrimitives() method, which only handles arrays. Because arrays are fixed, but I wanted to have a very large space to arbitrarily add new triangles to the array, my original idea was to make a large array, specifically
VertexPositionColor vertices = new VertexPositionColor[int.MaxValue];
but that ran my application out of memory. So what I'm wondering is how to approach this memory/performance issue best.
- Is there an easy way to increase the amount of memory allocated to the stack whenever my program runs?
- Would it be beneficial to store the array on the heap instead? And would I have to build my own allocator if I wanted to do that?
- Or is my best approach simply to use a LinkedList and deal with the extra processing required to copy it to an array every frame?