GC question
Adam D. Ruppe via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Feb 4 07:23:53 PST 2017
On Saturday, 4 February 2017 at 12:56:55 UTC, osa1 wrote:
> - Automatic but conservative. Can leak at any time.
All GCs are prone to leak, including precise ones. The point of
garbage collection is not to prevent leaks, but rather to prevent
use-after-free bugs.
Granted, the D 32 bit GC is more prone to leak than most others
(including D 64 bit), but this isn't as horrible as you're
believing, it does it's *main* job pretty well just at the cost
of higher memory consumption, which we can often afford.
And if you can't, manual management of large arrays tends to be
relatively simple anyway. For example, my png.d used to leak
something nasty in 32 bit because it used GC-allocated large
temporary buffers while decompressing images. But, since they
were temporary buffers, it was really easy to just `scope(exit)
free(buffer);` after allocating to let them be freed at the end
of the function. Then the memory consumption cut in half.
More information about the Digitalmars-d-learn
mailing list