Imagine I have a very short-lived class: void print(File f) { PrinterManager pm = new PrinterManager(); pm.print(f); }
My understanding is that PrinterManager will be GC allocated, and when it goes out of scope, the GC will possibly clean it up at some point in the future. But I know that this class won't be used anywhere, I want to clean it up right now so that GC doesn't waste time later. In C++ it'd be handled by RAII, pm would be a unique_ptr<PrinterManager>. How to do it in D?