Re:Chris Lattner on garbage collection vs. Automatic Referen...
by davnn on Sunday April 24, 2022 @12:44AM
(#31141361)
CUDA.jl apparently uses Julia‘s GC to free up GPU resources, see https://cuda.juliagpu.org/stable/usage/memory/
Re:Chris Lattner on garbage collection vs. Automatic Referen...
by 12thwonder on Sunday April 24, 2022 @01:51AM
(#31141605)
good to know, thanks!
I personally would like to know when the GPU resources become available (freed) thus still inclined to prefer RC over GC tho.
Re:Chris Lattner on garbage collection vs. Automatic Referen...
by kazinator on Monday April 25, 2022 @02:40AM
(#31151283)
No it isn't. Chris put his foot in his mouth and went on about how an advantage of garbage collection is that it moves objects. Not all garbage collection moves objects. Garbage collection that does not move objects does not have any such interop problem. Furthermore, even GC that does move objects can avoid that particular interop problem if it simply avoids moving foreign objects. E.g. suppose a foreign object is managed by some gc-heap object of type "foreign pointer". That managing object can be moved during GC, but if the actual foreign pointer doesn't change. If that pointer is all that the foreign code knows about, then there is no problem. Don't give foreign code any pointers to your heap objects and you're good.
in addition, if your system requires precise control over when and when not to use CPU, like resource-intensive gaming, browsers, OS, then GC may not be a good choice.
lastly, if you are using GPU via graphics API, I do not know any API that can garbage collect GPU memory but RC can naturally extend memory cleanup code to cleanup GPU memory as well quite easily.