#924 – You Shouldn’t Normally Worry about Memory Management

Because the Common Language Runtime (CLR) implements automatic memory management for heap-based objects, you generally don’t need to worry about memory management for objects that your code creates.  Because the Garbage Collector (GC) takes care of automatically deleting objects that are no longer being referenced, you don’t need to worry about deleting objects or removing references to them.

Your code explicitly creates objects, but doesn’t need to worry about destroying them, or about releasing memory for objects no longer in use.

Your code can freely:

  • Create objects (instances of types)
  • Create references to objects
  • Change reference-type variables to refer to other objects
  • Allow objects to contain references to other objects

Your code typically will not:

  • Dereference objects (e.g. by setting a reference-typed variable to null)
  • Keep track of whether objects have been deleted or not
  • Interact with the Garbage Collector to impact how objects are destroyed
Advertisements

About Sean
Software developer in the Twin Cities area, passionate about .NET technologies. Equally passionate about my own personal projects related to family history and preservation of family stories and photos.

One Response to #924 – You Shouldn’t Normally Worry about Memory Management

  1. Pingback: LightSwitch Content Rollup In The Daily Six Pack: September 6, 2013

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: