Name: Anonymous 2011-09-16 10:36
So I've heard a couple arguments for this and I'd like to see what you think.
The allocation procedure under copying collectors is most definitely faster than malloc, as malloc has to search through fragments of memory for a sufficiently large block to reserve, whereas allocation under a CC is as simple as incrementing the free heap pointer, much like allocating a stack frame.
When the garbage collector is triggered, it must search through the live set of objects and copy each one over to the new heap. This takes time, but it is limited to the objects in the lives set, so as long as that is reasonably small, this shouldn't take very long. Also, no operation at all is needed on the objects that are no longer referenced. Under malloc and free, free must be called on each and every single one of these objects, the moment they become dead to the program.
I could see garbage collection performing poorly in comparison to malloc and free when the live set of objects is very large and many objects stay live for a very long time. The long living objects would require minimal time for management using malloc and free, whereas the garbage collector may traverse them many times. I suppose this is were using a generational copying collector can come in handy, however. So /prog/, what do think?
The allocation procedure under copying collectors is most definitely faster than malloc, as malloc has to search through fragments of memory for a sufficiently large block to reserve, whereas allocation under a CC is as simple as incrementing the free heap pointer, much like allocating a stack frame.
When the garbage collector is triggered, it must search through the live set of objects and copy each one over to the new heap. This takes time, but it is limited to the objects in the lives set, so as long as that is reasonably small, this shouldn't take very long. Also, no operation at all is needed on the objects that are no longer referenced. Under malloc and free, free must be called on each and every single one of these objects, the moment they become dead to the program.
I could see garbage collection performing poorly in comparison to malloc and free when the live set of objects is very large and many objects stay live for a very long time. The long living objects would require minimal time for management using malloc and free, whereas the garbage collector may traverse them many times. I suppose this is were using a generational copying collector can come in handy, however. So /prog/, what do think?