Sollicitatievraag bij Amazon

Explain how Java does Garbage Colleciton.

Antwoord op sollicitatievraag

Anoniem

16 jul 2010

adaptive implementation that uses multiple strategies based on the current strategy's performance. there are reference counting, mark&sweep, and stop© might be used. reference counting uses a map to record all the references being done on a given object. once the counting goes to zero the memory should be freed. this has a problem when there's circular referencing that is not being referenced by outside. mark&sweep has two runs. first mark all objects being used(referenced) then the second one sweeps (frees) all the objects not being used. this solves the circular referencing problem but momentarily stops the application. stop© also momentarily stops the application then copy all the objects being used to a new heap. the problem is it, again, moentarily stops the app and also requires additional heap. but it can nicely stack the heap as it copies objects from the old heap.

1