On Friday, 11 September 2015 at 14:47:15 UTC, Prudence wrote:
If it's never collected and the GC scans it every time, it means it adds a constant overhead to the GC for absolutely no reason, right?

GC overhead isn't quite constant, it happens only when you call for a collection cycle.

But the array would still be scanned to clean up dead objects referred to by the delegates. The array itself is never collected (since it is always referenced by the global), but if you null out some entries, the objects they pointed to may be collected.

It also then makes every dependency on it GC dependent(@nogc can't be used)? It just seems like it's the wrong way to go about it.

You can access an array without the GC. And if you manually allocate it, then there's no GCness to it at all.

Built in arrays and slices are not necessarily managed by the garbage collector. It depends on how you create and use them.

Reply via email to