Search code examples
javascriptnode.jsgoogle-chromegarbage-collectionv8

Does V8 garbage collection free memory?


I was reading the V8 docs and it says that the garbage collector "reclaims" memory.

My question is does it "reclaim" the memory to be used in its own heap or does it free it?

Thanks in advance.


Solution

  • The purpose of a garbage collector pass is to determine what memory is no longer used by the application. It is referred to as reclaiming because the GC is re-asserting that the memory is available for new allocations.

    Whether or not the memory is free'd immediately is dependent upon a lot of factors. In general the memory simply stays around owned by the GC and will be used for the next allocation by the program.