Survey referencing objects to an object

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Survey referencing objects to an object

Howard Oh
Hi.
To study why some unknown ShellView(NULL, 'ClassBrowserShell')are not being
garbage collected, I have
created two interesting methods for Object.

#referencingObjects answers a collection of objects that it hold
as a instance variable.

Object>>referencingObjects

 |objectCollector|
 objectCollector := Array writeStream.
  1 to: self class instSize do:
   [:index| |theObject|
   theObject := self instVarAt: index.
   objectCollector nextPut: theObject
   ].
 ^objectCollector contents


#referecedObjects answers a selection of objects that holds 'self' as an
instance variable from all objects.

referencedObjects

 |r|
 r := OrderedCollection new.
 ^Object allSubinstances select:
  [:object| object referencingObjects includes: self].

I'm not really getting a help from this because it cannot tell whether those
objects are referenced by the root. Any ideas?

Hwa Jong Oh


Reply | Threaded
Open this post in threaded view
|

Re: Survey referencing objects to an object

Blair McGlashan
Hwa Jong Oh

You wrote in message news:918spf$3cgqt$[hidden email]...

> To study why some unknown ShellView(NULL, 'ClassBrowserShell')are not
being

> garbage collected, I have
> created two interesting methods for Object.
>
> #referencingObjects answers a collection of objects that it hold
> as a instance variable.
>
> Object>>referencingObjects
> ...
>...
> #referecedObjects answers a selection of objects that holds 'self' as an
> instance variable from all objects.
>

Can I suggest trying out Object>>allReferences? It should be somewhat
faster.

>
> I'm not really getting a help from this because it cannot tell whether
those
> objects are referenced by the root. Any ideas?

Ah, now that is a tricky problem. I've been meaning to look at the reference
finder in Squeak for some time now to see if it is a useful tool. It
certainly ought to be possible to write something which will find the "root"
references that prevent whole nets of objects from being GC'd.

Regards

Blair


Reply | Threaded
Open this post in threaded view
|

Re: Survey referencing objects to an object

Howard Oh
Blair,

> Can I suggest trying out Object>>allReferences? It should be somewhat
> faster.

I adimit that allReferences is faster indeed. But replacing
#referencingOjbects with #allReferences causes #referencedObjects to halt. I
will look for the cause of the halt.

> Ah, now that is a tricky problem. I've been meaning to look at the
reference
> finder in Squeak for some time now to see if it is a useful tool. It
> certainly ought to be possible to write something which will find the
"root"
> references that prevent whole nets of objects from being GC'd.

I think Zombi removal techniques can a good topic or pattern for any GC'ing
languages like Smalltalk.
Can you introduce me to them?

Hwa Jong Oh