Advertisement
Advertisement


Common memory optimization


Question

What are the most common memory optimizations in csharp, dotnet 2.0. Wanted to see if there common things that people may not be doing by default in winform app

2008/10/02
1
4
10/2/2008 8:06:11 PM

Accepted Answer

  • use structs for small wrapper objects to avoid heap fragmentation
  • think carefully about object lifetimes, especially for large objects so they do not end up on the LOH unless you intend them to
  • think about allocations inside of a loop
  • make sure dynamically sized array will be of reasonable size, otherwise partition the problem
2010/11/09
9
11/9/2010 6:28:20 PM


Sealing as much classes as possible should also help. AFAIK this is one trick that SmartAssembly uses to reduce memory consumption.

2008/09/13

Source: https://stackoverflow.com/questions/60652
Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Email: [email protected]