Garbage Collector Articles

Strings are Immutable!

Working with strings is a common task in most apps but there are several ‘gotchas’ that can arise due to the immutable nature of a  String in .NET. Immutable simply means that once created it doesn’t change. This seems strange at first since the value of a string variable can indeed be altered : string […]

Read more
Uncategorized

Measure Memory Usage of .NET Applications

There are two main methods for measuring the memory usage of a .NET application, using the GC class or using System.Diagnostics Retrieve Your App’s Memory Utilization using the GC class The .NET Framework’s GC class contains many useful memory-related methods, including GetTotalMemory(), which returns the amount of memory the garbage collector believes is allocated to […]

Read more
Uncategorized

C# Garbage Collecting – Destructors Versus Dispose

In C# it is  illegal to call a destructor explicitly it must be called by the garbage collector. If you handle  unmanaged resources  that need to be closed and disposed of as soon as possible, you should implement the IDisposable interface.   IDisposable requires implementers to define one method, named Dispose(), to perform the necessary […]

Read more
Uncategorized

C# Destructor

As C# has an inbuilt garbage collection it is not necessary to explicitly destroy your objects. However, for objects which control unmanaged resources, these resources need to be explicitly freed when they are no longer require. In C#, implicit control over unmanaged resources is provided by a destructor, which can be called by the garbage […]

Read more
Uncategorized