Chapter 4, Memory Management
- Three: generation 0, generation 1, and generation 2.
- Objects less than 80,000 bytes are placed on the SOH.
- Objects 80,000 bytes or more are placed on the LOH.
- A strong reference is a reference that does not get garbage-collected.
- A weak reference is a reference that does get garbage-collected.
- Implement the
IDisposable
pattern. - Unsubscribe event listeners when they are no longer used. Dispose of event publishers or set them to null when they are no longer used.
Marshal.ReleaseComObject(object)
.- Make sure that any allocated memory is deallocated. Use the
IDisposable
pattern to ensure that memory is cleaned up when the object is disposed of.