I\'m programming a computer graphics application in Scala which uses a RGB class to return the color at a point in the image. As you can imagine, the function which return the c
Supposedly, and they are, short lived objects and I have read that the garbage collector should re-claim them quickly. However I'm still worried about it. How does the GC know that I'm throwing it away quickly? So confusing.
It doesn't know it. It assumes it. This is called the generational hypothesis on which all generational garbage collectors are built:
Objects which satisfy this hypothesis are very cheap (even cheaper, in fact, than malloc
and free
in languages like C), only objects which violate one or both assumptions are expensive.