|
|
Warp wrote:
> That would mean that the memory allocation engine knows ahead of time
> the order in which objects will be "forgotten" (ie. nothing points to them
> anymore so they can be freed) so that it can group them in contiguous
> memory. Of course this is impossible
Um, yes. So, the reasonable conclusion would be "my initial premise is
incorrect."
> The only other alternative is that it performs memory defragmentation
> before freeing the objects.
No. It usually performs memory defragmentation as a concurrent part of
freeing the objects.
> But that doesn't sound any faster than
> freeing the objects directly.
It depends on the ratio of freed objects to retained objects. If you
retain only 2% of the objects you created since the last GC, it's a net win.
> Oh, of course there's a third possibility: It doesn't free objects if
> freeing them would cause fragmentation. But then they would consume
> memory even though they are not used. Doesn't sound reasonable if that
> memory would be needed for something else.
That is generally only done in systems that use pointers rather than
references. (I.e., systems where the address of the object can't change
due to the semantics of the language, like C, rather than something like
Java where there's no way to get to the underlying address given the
refernece.) Optimistic garbage collection (GIYF) often works that way.
--
Darren New / San Diego, CA, USA (PST)
Just because you find out you are
telepathic, don't let it go to your head.
Post a reply to this message
|
|