Original Post
Ok so i have profiled my program as it keeps running out of memory and one of the most expensive operations for memory is using the .ToArray() method with a List.
The list is continuously changing (both size and values) so i am continuously updating the VertexBuffers with the following code.
[color=green]//Set all vertex buffers for streaming new data
_straightVertexBuffer.SetData(_straightFibreVertices.ToArray(), 0, [color=#2b91af]LockFlags.Discard);
_catmullVertexBuffer.SetData(_catmullSplineVertices.ToArray(), 0, [color=#2b91af]LockFlags.Discard);
_springVertexBuffer.SetData(_springVertices.ToArray(), 0, [color=#2b91af]LockFlags.Discard);[font=arial, verdana, tahoma, sans-serif]Unfortunately the VB does not like it when i simply setdata with the list itself hence why i have used the ToArray() method. The list itself is cleared and repopulated when required and the VB is subsequently updated. Am i using too much memory by creating the new array and is there a way of disposing it or is it something else?[/font][font="arial, verdana, tahoma, sans-serif"]Anyone any ideas?[/font][font="arial, verdana, tahoma, sans-serif"]Thanks [/font]
The list is continuously changing (both size and values) so i am continuously updating the VertexBuffers with the following code.
[color=green]//Set all vertex buffers for streaming new data
_straightVertexBuffer.SetData(_straightFibreVertices.ToArray(), 0, [color=#2b91af]LockFlags.Discard);
_catmullVertexBuffer.SetData(_catmullSplineVertices.ToArray(), 0, [color=#2b91af]LockFlags.Discard);
_springVertexBuffer.SetData(_springVertices.ToArray(), 0, [color=#2b91af]LockFlags.Discard);[font=arial, verdana, tahoma, sans-serif]Unfortunately the VB does not like it when i simply setdata with the list itself hence why i have used the ToArray() method. The list itself is cleared and repopulated when required and the VB is subsequently updated. Am i using too much memory by creating the new array and is there a way of disposing it or is it something else?[/font][font="arial, verdana, tahoma, sans-serif"]Anyone any ideas?[/font][font="arial, verdana, tahoma, sans-serif"]Thanks [/font]