Ray's playground

 

Item 16: Avoid Creating Unnecessary Objects(Effective C#)

  The Garbage Collector does an efficient job of managing the memory that your application uses. But remember that creating and destroying heap objects still takes time. Avoid creating excessive objects; don’t create what you don’t need. Also avoid creating multiple objects of reference types in local functions. Instead, consider promoting local variables to member variables, or create static objects of the most common instances of your types. Finally, consider creating mutable builder classes for immutable types.

posted on 2011-02-09 21:05  Ray Z  阅读(133)  评论(0编辑  收藏  举报

导航