Open ziriax opened 6 years ago
What is current status on this?
The advice still prevails. Calling Dispose on SharpDX object should always work. And indeed, the feature of auto-disposing has been made optional in SharpDX (you can still activate it via Configuration), but as stated I don't guarantee that it will always work.
Also, as you said, the Dispose pattern is mostly fine for single ownership, so if you can stick with this pattern it is better. If you can't, you have either to track things with AddRef/ReleaseRef (which is cumbersome) or let auto-dispose working.
Thanks! We really need destructible value types in C# so we can have smart pointers :-(
In the early days of SharpDX, it was adviced to explicitly call
Dispose
, not allowing the garbage collector to perform cleanup in the finalizers. Since the .NET runtime doesn't have a concept of GPU memory pressure, I assume this is still the case, but in the past, this often just crashed. This is even stated in the DirectX FAQ:What is current status on this? Since we are building a playground for experimenting, we don't care that much about device resources immediately being released, and we would like to just use the garbage collector.
Thanks a lot, Peter Verswyvelen