ASP.NET controls are objects that have properties and methods, just like any other objects in the .NET Framework. If you’re an experienced programmer, you might be wondering what happens to all the memory used for the objects that you create in ASP.NET applications such as the FileStream and StreamWriter objects created in the WriteFile method in the example application. The answer is that the garbage collector in the common language runtime cleans them up automatically when your application has finished with them.
Garbage collection is a process that the runtime performs to free
memory. By controlling how memory is allocated and freed, the runtime
can help prevent memory leaks caused by programming errors.