Think outside the box
Greg writes:
"Standard, out of the box .NET collections store references of type System.Object. We have a structure that we add to a collection. We add approx 2500 structure types to this collection.
Well, duh, if we are adding a structure, which is a value type, to a collection, which stores a reference type, the structure will get boxed and allocated on the heap 2500+ times! Its like creating a reference type 2500+ times!
Solution: use a reference type (class) vs. a structure in this case."
No no no!! Changing your struct into a class is a cop-out. You'll still be creating 2,500 references, and losing the benefits of value types (of course, that's assuming you really want a value type in this case).
The solution to the boxing/collection issue is to create a strongly-typed collection using an underlying store of the same type as the objects you are storing. If you want a vector-type collection for storing Int32's, you would base it on an Int32[] array, for example. There are several tools that can help you with this, including Collection Gen and whatever this thing's called.
Roll on generics.