In this chapter, we will look at the resource management techniques of D. We'll learn the following:
Avoiding the garbage collector
Making a reference-counted object
Manually managing class memory
Using scope guards to manage transactions
Creating an array replacement
Managing lent resources
Creating a NotNull struct
Using unique pointers
Using RAII and handling the limitations of class destructors
Introduction
Resource management is an important aspect of most programs. D's rich abstraction support makes it possible to use a variety of techniques, from script-like quick coding with the garbage collector to low-level manual control.