Chapter 14
Using garbage collection and resource management
After completing this chapter, you will be able to:
Explain the purpose of the garbage collector and how it works.
Manage system resources by using garbage collection.
Release a resource at a known point in time in an exception-safe manner by writing a
try
/finally
statement.Release a resource at a known point in time in an exception-safe manner by writing a
using
statement.Implement the
IDisposable
andIAsyncDisposable
interfaces to support exception-safe disposal in a class.
You’ve seen in earlier chapters how to create variables and objects, and you should understand how memory is allocated when you create variables and objects. (In case you don’t remember, value types are created ...
Get Microsoft Visual C# Step by Step, 10th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.