Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
Previous Versions
.NET Framework 3.0
Tools
Development Tools
FxCop
FxCop Warnings
 Avoid excessive locals

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
Visual Studio Team System
Avoid excessive locals

TypeName

AvoidExcessiveLocals

CheckId

CA1809

Category

Microsoft.Performance

Breaking Change

NonBreaking

A method contains more than 64 local variables, some of which might be compiler generated.

A common performance optimization is to store a value in a processor register instead of memory, which is referred to as "enregistering" the value. The common language runtime considers up to 64 local variables for enregistration. Variables that are not enregistered are placed on the stack and must be moved to a register before manipulation. To allow the possibility that all local variables get enregistered, limit the number of local variables to 64.

To fix a violation of this rule, refactor the implementation to use no more than 64 local variables.

It is safe to exclude a warning from this rule, or disable the rule entirely, if performance is not an issue.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Also a maintainability issue      David M. Kean   |   Edit   |   Show History
Having more than 64 locals variables in a member could also indicate a maintainability issue, and you might want to consider refactoring your code.
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker