[Vm-dev] Detecting objects that point to an object

Eliot Miranda eliot.miranda at gmail.com
Mon Jul 19 17:59:50 UTC 2010


On Mon, Jul 19, 2010 at 7:35 AM, Igor Stasenko <siguctua at gmail.com> wrote:

>
> Mariano, can you tell us, why you need to know, how many objects pointing
> to
> a specific one?
> The reference counting is well known solution to this, but it is less
> effective than garbage collection
> (in terms of memory management), since you have to touch the counters
> at each memory write.
>

and recursively when objects are freed.

Further, for two reasons one will also need a scan-mark garbage collector to
collect all garbage.  It is inevitable that one won't waste space on a
reference count that can hold the max number of references and so the system
will have to deal with a max count and have some objects with an overflowed
count.  Reference counting cannot easily deal with circularities and so a
cycle of references will result in non-zero ref counts for nodes in the
cycle and prevent garbage collection.




>
> On 19 July 2010 12:55, Mariano Martinez Peck <marianopeck at gmail.com>
> wrote:
> >
> > Ok...thanks for the answers...I think I will have to go in another way.
> But anyway, thanks
> >
> > mariano
> >
> > On Thu, Jul 15, 2010 at 6:43 PM, Andreas Raab <andreas.raab at gmx.de>
> wrote:
> >>
> >> On 7/15/2010 5:40 AM, Mariano Martinez Peck wrote:
> >>>
> >>> Hi folks. I need to know the objects (actually, only how many) that are
> >>> pointing to any object. So...I take an object X, and I want to know how
> >>> many objects are pointing to X.
> >>>
> >>> The only possible I see in Squeak VM is to do a full mark over all
> >>> objects in memory (or starting by the roots). This is time consuming
> and
> >>> I even need (maybe) to do this check (to know how many objects are
> >>> pointing to an object) for every single object.
> >>>
> >>> So...is there a faster solution for this? The only thing I can imagine
> >>> is to modify the object header, maybe create a new type, and add an
> >>> array with the addresses of the objects that are pointing to that
> >>> object. Or maybe just a counter that I can increase or decrease ?
> >>
> >> That's called "reference counting". It's not supported in Squeak.
> >>
> >> Cheers,
> >>  - Andreas
> >
> >
> >
>
>
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20100719/c977b27c/attachment.htm


More information about the Vm-dev mailing list