Common memory optimization
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
- 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
Use StringBuilder instead of directly modifying a string if you're performing many modifications to the same string.
Read more... Read less...
Sealing as much classes as possible should also help. AFAIK this is one trick that SmartAssembly uses to reduce memory consumption.