[M3devel] GC question
Tony Hosking
hosking at cs.purdue.edu
Tue Jan 15 00:09:08 CET 2008
On Jan 14, 2008, at 4:28 PM, Darko wrote:
> Yep, I want to replace one object with another. One application is
> to expand open arrays without searching large data structures for
> references to replace. Maybe a simpler question is can you increase
> the size of an allocated object without getting messy?
Not easily.
Old-time Smalltalk systems had an "Object become:" method that you
could use to reallocate in this way, but a level of indirection was
used to avoid having to scan the heap. How about using an explicit
level of indirection of your own? The WeakRef interface may be
useful to you here too, so that you can discard indirection state
when there are no other references to the object.
>
>
> On 14/01/2008, at 1:17 PM, Tony Hosking wrote:
>
>> I'm not sure what your purpose here might be. You shouldn't
>> assume anything about an object's precise location since the
>> collector is free to move it around. What are you trying to do?
>> If you are trying to *replace* one object with another and have
>> all references to the old object refer to the new object, then,
>> yes, you really need to get intimately involved with the GC, since
>> it will need to go through the whole heap and redirect those
>> references. It is doable, but messy, and probably requires that
>> all threads in the system be stopped while you pull off the
>> switch. To do it without stopping all the threads requires that
>> you do something much smarter (see papers on replicating GC...).
>>
>> On Jan 14, 2008, at 3:53 PM, Mika Nystrom wrote:
>>
>>> It would have to be able to return an error, no? If there's
>>> an ambiguous root pointing to the object...
>>>
>>>
>>> Darko writes:
>>>> Tony,
>>>>
>>>> I imagine you're intimately familiar with the garbage collector
>>>> implementation. If I wanted to implement a 'reallocate' function
>>>> that
>>>> preserved references to an object although the object was
>>>> reallocated,
>>>> ie change all existing references from the old object to the new
>>>> object, would this be straight forward using the code of the
>>>> current
>>>> GC implementation? Is there any existing function that might do
>>>> something like this already?
>>>>
>>>> Thanks,
>>>> Darko.
>>
More information about the M3devel
mailing list