More CodeCampOz stuff

I particularly enjoyed the presentations from Joel Pobar and Dominic Cooney yesterday. Joel talked about all the "chunky bits" in the CLR and Dominic talked about managed performance. Dominic mentioned some interesting techniques to achieve some better managed memory performance (and therefore better overall performance). I found a couple of useful techniques he mentioned and shown some below.

When defining an enum, if you only have a few items, then derive it from a smaller type to save space. By default, an enum is derived from an Int. So for eg.

public enum MyEnum : byte
{
   something,
   anotherthing,
   onemore,
   andthelast
}

Its only a small saving for one object, but if they are used a lot, it can add up over time.

Also, if you want to find out if you are excessively "boxing" objects in an assembly, go into ildasm and load up your assembly, have a look at the IL and use notepad to search for the word "box". If there is lots of them, then you might want to check your code to try and minimise the boxing. Easiest way is to load up your assembly in ILDASM, and use the 'File --> Dump' menu option to output the IL to a file. Load it up in notepad and search for " BOX" (note the space before the word so you dont get search hits from things like "ListBox" etc. Its easy to see where your boxing is occurring and you can determine and its interesting learning experience too.

 

No Comments