3 ms·
> when the gc next moves the object, it adds an extra field in which the original address is cached. Under this scheme, if I allocate object A at address 0, th
by derefr 4y ago
> when the gc next moves the object, it adds an extra field in which the original address is cached.
Under this scheme, if I allocate object A at address 0, then GC-move it to address 100 (such that it caches that it was "originally at" address 0); and then, with object A still alive, I allocate object B at address 0... then don't objects A and B both now have 0 as their identity hashcode?
(I'm guessing the answer here is "this only works with generational GC, and the GC generation sequence-number is an implicit part of the stateless-address hashcodes and an explicit part of the cached-in-member hashcodes")
- kaba0 4y agoMoving GCs usually copy the object to a new region, and redirect accesses to the old one to the new region. These regions are often used as generations, but they could just be two halves of the heap that flip between active and inactive state.