Errors, resources and memory

This part of the C# course is about failure and about memory. It starts with try, catch and finally, custom exceptions, filters and the text of an exception nobody caught, with the exit status a shell sees. A resource that must be closed follows, closed by using and await using, then the garbage collector: the heap, generations, a forced collection, weak references, finalizers, SafeHandle and the GC modes.

5.1 Exceptions try, catch, finally, the order of the blocks, the finally of a method that throws Open 5.2 Throwing and custom exceptions throw, a custom exception, InnerException, when to throw Open 5.3 Exception filters when, a filter that logs, the order of the catches Open 5.4 Unhandled exceptions and exit codes the real text, the status 134, AppDomain.UnhandledException Open 5.5 IDisposable and using a resource that must be closed, using, a using declaration Open 5.6 IAsyncDisposable and await using DisposeAsync, await using, an async resource Open 5.7 The garbage collector generations, a live object, GC.GetTotalMemory Open 5.8 GC.Collect and WeakReference a weak reference, the local that would not die, a forced collection, when GC.Collect is the wrong tool Open 5.9 Finalizers and SafeHandle a finalizer, why it is not a destructor, SafeHandle Open 5.10 GC modes and settings workstation against server GC, GCSettings, the DOTNET_ variables Open

Lessons