As far as I know, GC has a separate thread that stops all other threads periodically to clear the unused memory fields.

Windows Vista was (Linux does as well as far as I know) making use of whole memory and not freeing the memory until more space is needed.

What disadvantages would we have if GC was to be freeing memory only when allocation is requested, and not checking periodically?

If there is space (free space in heap can be tracked I guess) in heap still, there is no need to free anything. If there is no space, and there is unused memory, they can be freed first. If there is still not enough memory, finally the size of heap can be increased.

Reply via email to