DA0010: Expensive GetHashCode

Rule Id



.NET Framework Usage

Profiling methods


.NET Memory


GetHashCode functions should be cheap and not allocate any memory. Reduce complexity of hash code function if possible.

Message type


Calls to the GetHashCode method of the type are a significant proportion of the profiling data or the method allocates memory.

Hashing is a technique for rapidly locating a particular item in a large collection. Because hash tables can be very large and have to support very high rates of access, hash tables should be extremely efficient. An implication of this requirement is that GetHashCode methods in the .NET Framework should not allocate memory. Allocating memory increases the load on the garbage collector and exposes the method to potential delays if it become necessary to run garbage collection as a result of the allocation request.

Reduce the complexity of the method.

Community Additions