garbage collection questions

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

garbage collection questions

Paul DeBruicker
1. Is there a wiki entry about the GC somewhere that provides advice
about how to tune the GC using #setGCParameters?


2. If I have two objects with accessors:

Object subclass: #ObjectA
        instanceVariableNames: 'objectB'
        classVariableNames: ''
        poolDictionaries: ''
        category: 'Temp'

Object subclass: #ObjectB
        instanceVariableNames: 'objectA'
        classVariableNames: ''
        poolDictionaries: ''
        category: 'Temp'

and create an instance of each in a workspace and then set them up:

|a b|
a:=ObjectA new.
b:=ObjectB new.
a objectB: b.
b objectA: a.

and close the workspace then those instances of ObjectA & ObjectB will
never be garbage collected, correct?  Its my understanding that I'd need
to  nil out the instance variables of both instances to have them GCd as
they both refer strongly to each other.  Is that right?


3.  How can I learn when an incremental or full GC run will happen?  Is
it dependent upon on the size of new or old memory or the overall size
of the image or ... ? It seems like putting a #halt in a random spot
could easily lead to a stuck image.


Thanks for your help

Paul


Reply | Threaded
Open this post in threaded view
|

Re: garbage collection questions

Sven Van Caekenberghe-2

On 26 Oct 2012, at 21:41, Paul DeBruicker <[hidden email]> wrote:

> 2. If I have two objects with accessors:
>
> Object subclass: #ObjectA
> instanceVariableNames: 'objectB'
> classVariableNames: ''
> poolDictionaries: ''
> category: 'Temp'
>
> Object subclass: #ObjectB
> instanceVariableNames: 'objectA'
> classVariableNames: ''
> poolDictionaries: ''
> category: 'Temp'
>
> and create an instance of each in a workspace and then set them up:
>
> |a b|
> a:=ObjectA new.
> b:=ObjectB new.
> a objectB: b.
> b objectA: a.
>
> and close the workspace then those instances of ObjectA & ObjectB will never be garbage collected, correct?  Its my understanding that I'd need to  nil out the instance variables of both instances to have them GCd as they both refer strongly to each other.  Is that right?

That's a circular reference and should be no problem for the garbage collector.
Unless something else holds either a or b, like the workspace, an inspector, a debugger.

--
Sven Van Caekenberghe
http://stfx.eu
Smalltalk is the Red Pill




Reply | Threaded
Open this post in threaded view
|

Re: garbage collection questions

Igor Stasenko
On 27 October 2012 01:23, Sven Van Caekenberghe <[hidden email]> wrote:

>
> On 26 Oct 2012, at 21:41, Paul DeBruicker <[hidden email]> wrote:
>
>> 2. If I have two objects with accessors:
>>
>> Object subclass: #ObjectA
>>       instanceVariableNames: 'objectB'
>>       classVariableNames: ''
>>       poolDictionaries: ''
>>       category: 'Temp'
>>
>> Object subclass: #ObjectB
>>       instanceVariableNames: 'objectA'
>>       classVariableNames: ''
>>       poolDictionaries: ''
>>       category: 'Temp'
>>
>> and create an instance of each in a workspace and then set them up:
>>
>> |a b|
>> a:=ObjectA new.
>> b:=ObjectB new.
>> a objectB: b.
>> b objectA: a.
>>
>> and close the workspace then those instances of ObjectA & ObjectB will never be garbage collected, correct?  Its my understanding that I'd need to  nil out the instance variables of both instances to have them GCd as they both refer strongly to each other.  Is that right?
>
> That's a circular reference and should be no problem for the garbage collector.
> Unless something else holds either a or b, like the workspace, an inspector, a debugger.
>
or "restore workspace contents" utility.

> --
> Sven Van Caekenberghe
> http://stfx.eu
> Smalltalk is the Red Pill



--
Best regards,
Igor Stasenko.