1
Vote

Investigate best practice for C# running on XBOX

description

I've noticed a large number of sections of code that simply do not suit high frequency use when running under the compact framework on the XBOX.

Things to avoid;

Allocations - a library which allocates large blocks memory to the heap every frame is unsuitable as it will trigger Garbage Collections each 1MB allocated (this will create noticeable framerate hitches in most peoples games)
A struct array is still an instance of System.Array and so will be allocated - cache arrays and reuse them.
Tiny methods - if the code is very hight frequency the cost of a method call is very noticeable - in these critical sections of code try to inline as much as possible (including the operator overloads on XNA types such as vector2 etc.
Prefer multiplication to division - this is anecdotal but apparently you will save CPU cycles if you replace num/2f with num*.5f

I'm sure there are many other areas not addressed but I felt the need to raise a ticket as a great many people have contributed optimisation snippets and it appears that all have been ignored.

comments