Help with a WeakOrderedCollection and objects not being GCed

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

Help with a WeakOrderedCollection and objects not being GCed

Mariano Martinez Peck
Hi guys. I am since yesterday trying to find something and I cannot. So at this point I need external eyes :)
I have this little code:
   
    anObject := ClassWith2Var new.
    sharedObject := ClassWith1Var new.
    sharedObject var1: 'nose'.
    anObject var1: Date today.
    anObject var2: sharedObject.
   
    serializedObjects := FuelMareaSerializer new serializeAndWriteObject: anObject to: 'aFileName'.
    anObject := nil.
    sharedObject := nil.

    3 timesRepeat: [Smalltalk garbageCollect].
    serializedObjects inspect.



What is important here is that FuelMareaSerializer new serializeAndWriteObject: anObject to: 'aFileName' answers a WeakOrderedCollection with each object of the serialized graph (taking anObject as the root)
Now, if I print the tempVar serializedObjects I see:

a WeakOrderedCollection(ClassWith1Var ClassWith2Var Date DateAndTime Duration a ClassWith1Var a ClassWith2Var 3 August 2011 2011-08-03T00:00:00+02:00 0:02:00:00 1:00:00:00 86400 2455777 'nose' 0 7200)

WHYYYY??  why are all there if I put a nil to both, anObject and sharedObejct. This WeakOrderedCollection should be with all nils (except classes). Why are not being garbage collected?

If I explore, for example the tempVar sharedObejct, which is at serializedObjects at: 6   and then I put explore pointers I ONLY see the array of the WeakOrderedCollection pointing to it. I don't understand.

Any help is really appreaciated.

--
Mariano
http://marianopeck.wordpress.com

Reply | Threaded
Open this post in threaded view
|

Re: Help with a WeakOrderedCollection and objects not being GCed

Nicolas Cellier
I'm pretty sure the array inst var of your WeakOrderedColleciton is no
more a WeakArray but a simple Array.
This is because Pharo's WeakOrderedCollection is broken...

Every reference to Array from within OrderedCollection should be
replaced with message send (self arrayType).
See for example, OrderedCollection>>#grow

Nicolas

2011/8/3 Mariano Martinez Peck <[hidden email]>:

> Hi guys. I am since yesterday trying to find something and I cannot. So at
> this point I need external eyes :)
> I have this little code:
>
>     anObject := ClassWith2Var new.
>     sharedObject := ClassWith1Var new.
>     sharedObject var1: 'nose'.
>     anObject var1: Date today.
>     anObject var2: sharedObject.
>
>     serializedObjects := FuelMareaSerializer new serializeAndWriteObject:
> anObject to: 'aFileName'.
>     anObject := nil.
>     sharedObject := nil.
>
>     3 timesRepeat: [Smalltalk garbageCollect].
>     serializedObjects inspect.
>
>
>
> What is important here is that FuelMareaSerializer new
> serializeAndWriteObject: anObject to: 'aFileName' answers a
> WeakOrderedCollection with each object of the serialized graph (taking
> anObject as the root)
> Now, if I print the tempVar serializedObjects I see:
>
> a WeakOrderedCollection(ClassWith1Var ClassWith2Var Date DateAndTime
> Duration a ClassWith1Var a ClassWith2Var 3 August 2011
> 2011-08-03T00:00:00+02:00 0:02:00:00 1:00:00:00 86400 2455777 'nose' 0 7200)
>
> WHYYYY??  why are all there if I put a nil to both, anObject and
> sharedObejct. This WeakOrderedCollection should be with all nils (except
> classes). Why are not being garbage collected?
>
> If I explore, for example the tempVar sharedObejct, which is at
> serializedObjects at: 6   and then I put explore pointers I ONLY see the
> array of the WeakOrderedCollection pointing to it. I don't understand.
>
> Any help is really appreaciated.
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Help with a WeakOrderedCollection and objects not being GCed

Nicolas Cellier
http://code.google.com/p/pharo/issues/detail?id=4596

2011/8/3 Nicolas Cellier <[hidden email]>:

> I'm pretty sure the array inst var of your WeakOrderedColleciton is no
> more a WeakArray but a simple Array.
> This is because Pharo's WeakOrderedCollection is broken...
>
> Every reference to Array from within OrderedCollection should be
> replaced with message send (self arrayType).
> See for example, OrderedCollection>>#grow
>
> Nicolas
>
> 2011/8/3 Mariano Martinez Peck <[hidden email]>:
>> Hi guys. I am since yesterday trying to find something and I cannot. So at
>> this point I need external eyes :)
>> I have this little code:
>>
>>     anObject := ClassWith2Var new.
>>     sharedObject := ClassWith1Var new.
>>     sharedObject var1: 'nose'.
>>     anObject var1: Date today.
>>     anObject var2: sharedObject.
>>
>>     serializedObjects := FuelMareaSerializer new serializeAndWriteObject:
>> anObject to: 'aFileName'.
>>     anObject := nil.
>>     sharedObject := nil.
>>
>>     3 timesRepeat: [Smalltalk garbageCollect].
>>     serializedObjects inspect.
>>
>>
>>
>> What is important here is that FuelMareaSerializer new
>> serializeAndWriteObject: anObject to: 'aFileName' answers a
>> WeakOrderedCollection with each object of the serialized graph (taking
>> anObject as the root)
>> Now, if I print the tempVar serializedObjects I see:
>>
>> a WeakOrderedCollection(ClassWith1Var ClassWith2Var Date DateAndTime
>> Duration a ClassWith1Var a ClassWith2Var 3 August 2011
>> 2011-08-03T00:00:00+02:00 0:02:00:00 1:00:00:00 86400 2455777 'nose' 0 7200)
>>
>> WHYYYY??  why are all there if I put a nil to both, anObject and
>> sharedObejct. This WeakOrderedCollection should be with all nils (except
>> classes). Why are not being garbage collected?
>>
>> If I explore, for example the tempVar sharedObejct, which is at
>> serializedObjects at: 6   and then I put explore pointers I ONLY see the
>> array of the WeakOrderedCollection pointing to it. I don't understand.
>>
>> Any help is really appreaciated.
>>
>> --
>> Mariano
>> http://marianopeck.wordpress.com
>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: Help with a WeakOrderedCollection and objects not being GCed

Mariano Martinez Peck
In reply to this post by Nicolas Cellier


On Wed, Aug 3, 2011 at 12:42 PM, Nicolas Cellier <[hidden email]> wrote:
I'm pretty sure the array inst var of your WeakOrderedColleciton is no
more a WeakArray but a simple Array.

Yes, indeed, it is a normal Array and that cought my attention. But since I have no idea about Weak stuff...I also noticed that WeakOrderedCollection is declared as:

OrderedCollection subclass: #WeakOrderedCollection
    instanceVariableNames: ''
    classVariableNames: ''
    poolDictionaries: ''
    category: 'Collections-Weak'

instead of using the #weakSubclass: ... message:

OrderedCollection weakSubclass: #WeakOrderedCollection
    instanceVariableNames: ''
    classVariableNames: ''
    poolDictionaries: ''
    category: 'Collections-Weak'

 
This is because Pharo's WeakOrderedCollection is broken...


Do you know a weak collection that is not broken in Pharo and let me do a addLast: ?
 
Every reference to Array from within OrderedCollection should be
replaced with message send (self arrayType).
See for example, OrderedCollection>>#grow


Thanks. I will check how many there are and try to fix them.
 
Nicolas

2011/8/3 Mariano Martinez Peck <[hidden email]>:
> Hi guys. I am since yesterday trying to find something and I cannot. So at
> this point I need external eyes :)
> I have this little code:
>
>     anObject := ClassWith2Var new.
>     sharedObject := ClassWith1Var new.
>     sharedObject var1: 'nose'.
>     anObject var1: Date today.
>     anObject var2: sharedObject.
>
>     serializedObjects := FuelMareaSerializer new serializeAndWriteObject:
> anObject to: 'aFileName'.
>     anObject := nil.
>     sharedObject := nil.
>
>     3 timesRepeat: [Smalltalk garbageCollect].
>     serializedObjects inspect.
>
>
>
> What is important here is that FuelMareaSerializer new
> serializeAndWriteObject: anObject to: 'aFileName' answers a
> WeakOrderedCollection with each object of the serialized graph (taking
> anObject as the root)
> Now, if I print the tempVar serializedObjects I see:
>
> a WeakOrderedCollection(ClassWith1Var ClassWith2Var Date DateAndTime
> Duration a ClassWith1Var a ClassWith2Var 3 August 2011
> 2011-08-03T00:00:00+02:00 0:02:00:00 1:00:00:00 86400 2455777 'nose' 0 7200)
>
> WHYYYY??  why are all there if I put a nil to both, anObject and
> sharedObejct. This WeakOrderedCollection should be with all nils (except
> classes). Why are not being garbage collected?
>
> If I explore, for example the tempVar sharedObejct, which is at
> serializedObjects at: 6   and then I put explore pointers I ONLY see the
> array of the WeakOrderedCollection pointing to it. I don't understand.
>
> Any help is really appreaciated.
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
>




--
Mariano
http://marianopeck.wordpress.com

Reply | Threaded
Open this post in threaded view
|

Re: Help with a WeakOrderedCollection and objects not being GCed

Mariano Martinez Peck
btw...how can I change OrderedCollection>>grow
without shooting my foots?

On Wed, Aug 3, 2011 at 12:51 PM, Mariano Martinez Peck <[hidden email]> wrote:


On Wed, Aug 3, 2011 at 12:42 PM, Nicolas Cellier <[hidden email]> wrote:
I'm pretty sure the array inst var of your WeakOrderedColleciton is no
more a WeakArray but a simple Array.

Yes, indeed, it is a normal Array and that cought my attention. But since I have no idea about Weak stuff...I also noticed that WeakOrderedCollection is declared as:

OrderedCollection subclass: #WeakOrderedCollection
    instanceVariableNames: ''
    classVariableNames: ''
    poolDictionaries: ''
    category: 'Collections-Weak'

instead of using the #weakSubclass: ... message:

OrderedCollection weakSubclass: #WeakOrderedCollection
    instanceVariableNames: ''
    classVariableNames: ''
    poolDictionaries: ''
    category: 'Collections-Weak'

 
This is because Pharo's WeakOrderedCollection is broken...


Do you know a weak collection that is not broken in Pharo and let me do a addLast: ?
 
Every reference to Array from within OrderedCollection should be
replaced with message send (self arrayType).
See for example, OrderedCollection>>#grow


Thanks. I will check how many there are and try to fix them.
 
Nicolas

2011/8/3 Mariano Martinez Peck <[hidden email]>:
> Hi guys. I am since yesterday trying to find something and I cannot. So at
> this point I need external eyes :)
> I have this little code:
>
>     anObject := ClassWith2Var new.
>     sharedObject := ClassWith1Var new.
>     sharedObject var1: 'nose'.
>     anObject var1: Date today.
>     anObject var2: sharedObject.
>
>     serializedObjects := FuelMareaSerializer new serializeAndWriteObject:
> anObject to: 'aFileName'.
>     anObject := nil.
>     sharedObject := nil.
>
>     3 timesRepeat: [Smalltalk garbageCollect].
>     serializedObjects inspect.
>
>
>
> What is important here is that FuelMareaSerializer new
> serializeAndWriteObject: anObject to: 'aFileName' answers a
> WeakOrderedCollection with each object of the serialized graph (taking
> anObject as the root)
> Now, if I print the tempVar serializedObjects I see:
>
> a WeakOrderedCollection(ClassWith1Var ClassWith2Var Date DateAndTime
> Duration a ClassWith1Var a ClassWith2Var 3 August 2011
> 2011-08-03T00:00:00+02:00 0:02:00:00 1:00:00:00 86400 2455777 'nose' 0 7200)
>
> WHYYYY??  why are all there if I put a nil to both, anObject and
> sharedObejct. This WeakOrderedCollection should be with all nils (except
> classes). Why are not being garbage collected?
>
> If I explore, for example the tempVar sharedObejct, which is at
> serializedObjects at: 6   and then I put explore pointers I ONLY see the
> array of the WeakOrderedCollection pointing to it. I don't understand.
>
> Any help is really appreaciated.
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
>




--



--
Mariano
http://marianopeck.wordpress.com

Reply | Threaded
Open this post in threaded view
|

Re: Help with a WeakOrderedCollection and objects not being GCed

Nicolas Cellier
You replace Array with self arrayType, that's all.
But there is better, Pharo already has growAtFirst and growAtLast
which are correct.
Use them instead of grow.
See SLICE in inbox.

Nicolas

2011/8/3 Mariano Martinez Peck <[hidden email]>:

> btw...how can I change OrderedCollection>>grow
> without shooting my foots?
>
> On Wed, Aug 3, 2011 at 12:51 PM, Mariano Martinez Peck
> <[hidden email]> wrote:
>>
>>
>> On Wed, Aug 3, 2011 at 12:42 PM, Nicolas Cellier
>> <[hidden email]> wrote:
>>>
>>> I'm pretty sure the array inst var of your WeakOrderedColleciton is no
>>> more a WeakArray but a simple Array.
>>
>> Yes, indeed, it is a normal Array and that cought my attention. But since
>> I have no idea about Weak stuff...I also noticed that WeakOrderedCollection
>> is declared as:
>>
>> OrderedCollection subclass: #WeakOrderedCollection
>>     instanceVariableNames: ''
>>     classVariableNames: ''
>>     poolDictionaries: ''
>>     category: 'Collections-Weak'
>>
>> instead of using the #weakSubclass: ... message:
>>
>> OrderedCollection weakSubclass: #WeakOrderedCollection
>>     instanceVariableNames: ''
>>     classVariableNames: ''
>>     poolDictionaries: ''
>>     category: 'Collections-Weak'
>>
>>
>>>
>>> This is because Pharo's WeakOrderedCollection is broken...
>>>
>>
>> Do you know a weak collection that is not broken in Pharo and let me do a
>> addLast: ?
>>
>>>
>>> Every reference to Array from within OrderedCollection should be
>>> replaced with message send (self arrayType).
>>> See for example, OrderedCollection>>#grow
>>>
>>
>> Thanks. I will check how many there are and try to fix them.
>>
>>>
>>> Nicolas
>>>
>>> 2011/8/3 Mariano Martinez Peck <[hidden email]>:
>>> > Hi guys. I am since yesterday trying to find something and I cannot. So
>>> > at
>>> > this point I need external eyes :)
>>> > I have this little code:
>>> >
>>> >     anObject := ClassWith2Var new.
>>> >     sharedObject := ClassWith1Var new.
>>> >     sharedObject var1: 'nose'.
>>> >     anObject var1: Date today.
>>> >     anObject var2: sharedObject.
>>> >
>>> >     serializedObjects := FuelMareaSerializer new
>>> > serializeAndWriteObject:
>>> > anObject to: 'aFileName'.
>>> >     anObject := nil.
>>> >     sharedObject := nil.
>>> >
>>> >     3 timesRepeat: [Smalltalk garbageCollect].
>>> >     serializedObjects inspect.
>>> >
>>> >
>>> >
>>> > What is important here is that FuelMareaSerializer new
>>> > serializeAndWriteObject: anObject to: 'aFileName' answers a
>>> > WeakOrderedCollection with each object of the serialized graph (taking
>>> > anObject as the root)
>>> > Now, if I print the tempVar serializedObjects I see:
>>> >
>>> > a WeakOrderedCollection(ClassWith1Var ClassWith2Var Date DateAndTime
>>> > Duration a ClassWith1Var a ClassWith2Var 3 August 2011
>>> > 2011-08-03T00:00:00+02:00 0:02:00:00 1:00:00:00 86400 2455777 'nose' 0
>>> > 7200)
>>> >
>>> > WHYYYY??  why are all there if I put a nil to both, anObject and
>>> > sharedObejct. This WeakOrderedCollection should be with all nils
>>> > (except
>>> > classes). Why are not being garbage collected?
>>> >
>>> > If I explore, for example the tempVar sharedObejct, which is at
>>> > serializedObjects at: 6   and then I put explore pointers I ONLY see
>>> > the
>>> > array of the WeakOrderedCollection pointing to it. I don't understand.
>>> >
>>> > Any help is really appreaciated.
>>> >
>>> > --
>>> > Mariano
>>> > http://marianopeck.wordpress.com
>>> >
>>> >
>>>
>>
>>
>>
>> --
>> Mariano
>> http://marianopeck.wordpress.com
>>
>
>
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Help with a WeakOrderedCollection and objects not being GCed

Henrik Sperre Johansen
In reply to this post by Mariano Martinez Peck

On Aug 3, 2011, at 12:51 38PM, Mariano Martinez Peck wrote:



On Wed, Aug 3, 2011 at 12:42 PM, Nicolas Cellier <[hidden email]> wrote:
I'm pretty sure the array inst var of your WeakOrderedColleciton is no
more a WeakArray but a simple Array.

Yes, indeed, it is a normal Array and that cought my attention. But since I have no idea about Weak stuff...I also noticed that WeakOrderedCollection is declared as:

OrderedCollection subclass: #WeakOrderedCollection
    instanceVariableNames: ''
    classVariableNames: ''
    poolDictionaries: ''
    category: 'Collections-Weak'

instead of using the #weakSubclass: ... message:

OrderedCollection weakSubclass: #WeakOrderedCollection
    instanceVariableNames: ''
    classVariableNames: ''
    poolDictionaries: ''
    category: 'Collections-Weak'

Because the slots of the WeakOrderedCollection aren't weak. Those if its instance variable array is.

 
This is because Pharo's WeakOrderedCollection is broken...


Do you know a weak collection that is not broken in Pharo and let me do a addLast: ?
 
Every reference to Array from within OrderedCollection should be
replaced with message send (self arrayType).
See for example, OrderedCollection>>#grow


Thanks. I will check how many there are and try to fix them.

Only grow. (Well, asArray too, but that doesn't make sense to change)

Cheers,
Henry
Reply | Threaded
Open this post in threaded view
|

Re: Help with a WeakOrderedCollection and objects not being GCed

Mariano Martinez Peck
In reply to this post by Nicolas Cellier


On Wed, Aug 3, 2011 at 1:01 PM, Nicolas Cellier <[hidden email]> wrote:
You replace Array with self arrayType, that's all.

Here my images freezes and CPU goes 100%. I guess because compiling/saving a method uses OrderedCollection grow at the same time.
 
But there is better, Pharo already has growAtFirst and growAtLast
which are correct.
Use them instead of grow.
See SLICE in inbox.

I cannot load it since it freezes in "Cleaning Up". It can be the same reason as why I cannot save the modification.
I am in Pharo1.3
Latest update: #13277

Thanks a lot for the help!
 

Nicolas

2011/8/3 Mariano Martinez Peck <[hidden email]>:
> btw...how can I change OrderedCollection>>grow
> without shooting my foots?
>
> On Wed, Aug 3, 2011 at 12:51 PM, Mariano Martinez Peck
> <[hidden email]> wrote:
>>
>>
>> On Wed, Aug 3, 2011 at 12:42 PM, Nicolas Cellier
>> <[hidden email]> wrote:
>>>
>>> I'm pretty sure the array inst var of your WeakOrderedColleciton is no
>>> more a WeakArray but a simple Array.
>>
>> Yes, indeed, it is a normal Array and that cought my attention. But since
>> I have no idea about Weak stuff...I also noticed that WeakOrderedCollection
>> is declared as:
>>
>> OrderedCollection subclass: #WeakOrderedCollection
>>     instanceVariableNames: ''
>>     classVariableNames: ''
>>     poolDictionaries: ''
>>     category: 'Collections-Weak'
>>
>> instead of using the #weakSubclass: ... message:
>>
>> OrderedCollection weakSubclass: #WeakOrderedCollection
>>     instanceVariableNames: ''
>>     classVariableNames: ''
>>     poolDictionaries: ''
>>     category: 'Collections-Weak'
>>
>>
>>>
>>> This is because Pharo's WeakOrderedCollection is broken...
>>>
>>
>> Do you know a weak collection that is not broken in Pharo and let me do a
>> addLast: ?
>>
>>>
>>> Every reference to Array from within OrderedCollection should be
>>> replaced with message send (self arrayType).
>>> See for example, OrderedCollection>>#grow
>>>
>>
>> Thanks. I will check how many there are and try to fix them.
>>
>>>
>>> Nicolas
>>>
>>> 2011/8/3 Mariano Martinez Peck <[hidden email]>:
>>> > Hi guys. I am since yesterday trying to find something and I cannot. So
>>> > at
>>> > this point I need external eyes :)
>>> > I have this little code:
>>> >
>>> >     anObject := ClassWith2Var new.
>>> >     sharedObject := ClassWith1Var new.
>>> >     sharedObject var1: 'nose'.
>>> >     anObject var1: Date today.
>>> >     anObject var2: sharedObject.
>>> >
>>> >     serializedObjects := FuelMareaSerializer new
>>> > serializeAndWriteObject:
>>> > anObject to: 'aFileName'.
>>> >     anObject := nil.
>>> >     sharedObject := nil.
>>> >
>>> >     3 timesRepeat: [Smalltalk garbageCollect].
>>> >     serializedObjects inspect.
>>> >
>>> >
>>> >
>>> > What is important here is that FuelMareaSerializer new
>>> > serializeAndWriteObject: anObject to: 'aFileName' answers a
>>> > WeakOrderedCollection with each object of the serialized graph (taking
>>> > anObject as the root)
>>> > Now, if I print the tempVar serializedObjects I see:
>>> >
>>> > a WeakOrderedCollection(ClassWith1Var ClassWith2Var Date DateAndTime
>>> > Duration a ClassWith1Var a ClassWith2Var 3 August 2011
>>> > 2011-08-03T00:00:00+02:00 0:02:00:00 1:00:00:00 86400 2455777 'nose' 0
>>> > 7200)
>>> >
>>> > WHYYYY??  why are all there if I put a nil to both, anObject and
>>> > sharedObejct. This WeakOrderedCollection should be with all nils
>>> > (except
>>> > classes). Why are not being garbage collected?
>>> >
>>> > If I explore, for example the tempVar sharedObejct, which is at
>>> > serializedObjects at: 6   and then I put explore pointers I ONLY see
>>> > the
>>> > array of the WeakOrderedCollection pointing to it. I don't understand.
>>> >
>>> > Any help is really appreaciated.
>>> >
>>> > --
>>> > Mariano
>>> > http://marianopeck.wordpress.com
>>> >
>>> >
>>>
>>
>>
>>
>> --
>> Mariano
>> http://marianopeck.wordpress.com
>>
>
>
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
>




--
Mariano
http://marianopeck.wordpress.com

Reply | Threaded
Open this post in threaded view
|

Re: Help with a WeakOrderedCollection and objects not being GCed

Nicolas Cellier
Oh I see, for the SLICE, this is again the Pharo's version of
MCPackageLoader>>basicLoad which is striking.
In Squeak trunk it would work because removals are performed AFTER
methodAdditions/Changes.
In Pharo, removals are performed BEFORE, so yes, the SLICE needs to be
split in two parts...
Or you can just manually merge it (apply the removal after...).

I'm eager to see a true atomic load with a single massive becomeForward: :)
IMHO, this should be coupled with lazy initializations mechanism as I
proposed once (based on pragmas).

Now if you simply modify grow from within a browser, I see no obvious
reason why it would fail...

Nicolas

2011/8/3 Mariano Martinez Peck <[hidden email]>:

>
>
> On Wed, Aug 3, 2011 at 1:01 PM, Nicolas Cellier
> <[hidden email]> wrote:
>>
>> You replace Array with self arrayType, that's all.
>
> Here my images freezes and CPU goes 100%. I guess because compiling/saving a
> method uses OrderedCollection grow at the same time.
>
>>
>> But there is better, Pharo already has growAtFirst and growAtLast
>> which are correct.
>> Use them instead of grow.
>> See SLICE in inbox.
>
> I cannot load it since it freezes in "Cleaning Up". It can be the same
> reason as why I cannot save the modification.
> I am in Pharo1.3
> Latest update: #13277
>
> Thanks a lot for the help!
>
>>
>> Nicolas
>>
>> 2011/8/3 Mariano Martinez Peck <[hidden email]>:
>> > btw...how can I change OrderedCollection>>grow
>> > without shooting my foots?
>> >
>> > On Wed, Aug 3, 2011 at 12:51 PM, Mariano Martinez Peck
>> > <[hidden email]> wrote:
>> >>
>> >>
>> >> On Wed, Aug 3, 2011 at 12:42 PM, Nicolas Cellier
>> >> <[hidden email]> wrote:
>> >>>
>> >>> I'm pretty sure the array inst var of your WeakOrderedColleciton is no
>> >>> more a WeakArray but a simple Array.
>> >>
>> >> Yes, indeed, it is a normal Array and that cought my attention. But
>> >> since
>> >> I have no idea about Weak stuff...I also noticed that
>> >> WeakOrderedCollection
>> >> is declared as:
>> >>
>> >> OrderedCollection subclass: #WeakOrderedCollection
>> >>     instanceVariableNames: ''
>> >>     classVariableNames: ''
>> >>     poolDictionaries: ''
>> >>     category: 'Collections-Weak'
>> >>
>> >> instead of using the #weakSubclass: ... message:
>> >>
>> >> OrderedCollection weakSubclass: #WeakOrderedCollection
>> >>     instanceVariableNames: ''
>> >>     classVariableNames: ''
>> >>     poolDictionaries: ''
>> >>     category: 'Collections-Weak'
>> >>
>> >>
>> >>>
>> >>> This is because Pharo's WeakOrderedCollection is broken...
>> >>>
>> >>
>> >> Do you know a weak collection that is not broken in Pharo and let me do
>> >> a
>> >> addLast: ?
>> >>
>> >>>
>> >>> Every reference to Array from within OrderedCollection should be
>> >>> replaced with message send (self arrayType).
>> >>> See for example, OrderedCollection>>#grow
>> >>>
>> >>
>> >> Thanks. I will check how many there are and try to fix them.
>> >>
>> >>>
>> >>> Nicolas
>> >>>
>> >>> 2011/8/3 Mariano Martinez Peck <[hidden email]>:
>> >>> > Hi guys. I am since yesterday trying to find something and I cannot.
>> >>> > So
>> >>> > at
>> >>> > this point I need external eyes :)
>> >>> > I have this little code:
>> >>> >
>> >>> >     anObject := ClassWith2Var new.
>> >>> >     sharedObject := ClassWith1Var new.
>> >>> >     sharedObject var1: 'nose'.
>> >>> >     anObject var1: Date today.
>> >>> >     anObject var2: sharedObject.
>> >>> >
>> >>> >     serializedObjects := FuelMareaSerializer new
>> >>> > serializeAndWriteObject:
>> >>> > anObject to: 'aFileName'.
>> >>> >     anObject := nil.
>> >>> >     sharedObject := nil.
>> >>> >
>> >>> >     3 timesRepeat: [Smalltalk garbageCollect].
>> >>> >     serializedObjects inspect.
>> >>> >
>> >>> >
>> >>> >
>> >>> > What is important here is that FuelMareaSerializer new
>> >>> > serializeAndWriteObject: anObject to: 'aFileName' answers a
>> >>> > WeakOrderedCollection with each object of the serialized graph
>> >>> > (taking
>> >>> > anObject as the root)
>> >>> > Now, if I print the tempVar serializedObjects I see:
>> >>> >
>> >>> > a WeakOrderedCollection(ClassWith1Var ClassWith2Var Date DateAndTime
>> >>> > Duration a ClassWith1Var a ClassWith2Var 3 August 2011
>> >>> > 2011-08-03T00:00:00+02:00 0:02:00:00 1:00:00:00 86400 2455777 'nose'
>> >>> > 0
>> >>> > 7200)
>> >>> >
>> >>> > WHYYYY??  why are all there if I put a nil to both, anObject and
>> >>> > sharedObejct. This WeakOrderedCollection should be with all nils
>> >>> > (except
>> >>> > classes). Why are not being garbage collected?
>> >>> >
>> >>> > If I explore, for example the tempVar sharedObejct, which is at
>> >>> > serializedObjects at: 6   and then I put explore pointers I ONLY see
>> >>> > the
>> >>> > array of the WeakOrderedCollection pointing to it. I don't
>> >>> > understand.
>> >>> >
>> >>> > Any help is really appreaciated.
>> >>> >
>> >>> > --
>> >>> > Mariano
>> >>> > http://marianopeck.wordpress.com
>> >>> >
>> >>> >
>> >>>
>> >>
>> >>
>> >>
>> >> --
>> >> Mariano
>> >> http://marianopeck.wordpress.com
>> >>
>> >
>> >
>> >
>> > --
>> > Mariano
>> > http://marianopeck.wordpress.com
>> >
>> >
>>
>
>
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Help with a WeakOrderedCollection and objects not being GCed

Mariano Martinez Peck
Thanks a lot Nicolas and Henrik.  I have split the slice and it works!
I will upload soon both slides, part1 and part2 and a test for it.

On Wed, Aug 3, 2011 at 1:49 PM, Nicolas Cellier <[hidden email]> wrote:
Oh I see, for the SLICE, this is again the Pharo's version of
MCPackageLoader>>basicLoad which is striking.
In Squeak trunk it would work because removals are performed AFTER
methodAdditions/Changes.
In Pharo, removals are performed BEFORE, so yes, the SLICE needs to be
split in two parts...
Or you can just manually merge it (apply the removal after...).

I'm eager to see a true atomic load with a single massive becomeForward: :)
IMHO, this should be coupled with lazy initializations mechanism as I
proposed once (based on pragmas).

Now if you simply modify grow from within a browser, I see no obvious
reason why it would fail...

Nicolas

2011/8/3 Mariano Martinez Peck <[hidden email]>:
>
>
> On Wed, Aug 3, 2011 at 1:01 PM, Nicolas Cellier
> <[hidden email]> wrote:
>>
>> You replace Array with self arrayType, that's all.
>
> Here my images freezes and CPU goes 100%. I guess because compiling/saving a
> method uses OrderedCollection grow at the same time.
>
>>
>> But there is better, Pharo already has growAtFirst and growAtLast
>> which are correct.
>> Use them instead of grow.
>> See SLICE in inbox.
>
> I cannot load it since it freezes in "Cleaning Up". It can be the same
> reason as why I cannot save the modification.
> I am in Pharo1.3
> Latest update: #13277
>
> Thanks a lot for the help!
>
>>
>> Nicolas
>>
>> 2011/8/3 Mariano Martinez Peck <[hidden email]>:
>> > btw...how can I change OrderedCollection>>grow
>> > without shooting my foots?
>> >
>> > On Wed, Aug 3, 2011 at 12:51 PM, Mariano Martinez Peck
>> > <[hidden email]> wrote:
>> >>
>> >>
>> >> On Wed, Aug 3, 2011 at 12:42 PM, Nicolas Cellier
>> >> <[hidden email]> wrote:
>> >>>
>> >>> I'm pretty sure the array inst var of your WeakOrderedColleciton is no
>> >>> more a WeakArray but a simple Array.
>> >>
>> >> Yes, indeed, it is a normal Array and that cought my attention. But
>> >> since
>> >> I have no idea about Weak stuff...I also noticed that
>> >> WeakOrderedCollection
>> >> is declared as:
>> >>
>> >> OrderedCollection subclass: #WeakOrderedCollection
>> >>     instanceVariableNames: ''
>> >>     classVariableNames: ''
>> >>     poolDictionaries: ''
>> >>     category: 'Collections-Weak'
>> >>
>> >> instead of using the #weakSubclass: ... message:
>> >>
>> >> OrderedCollection weakSubclass: #WeakOrderedCollection
>> >>     instanceVariableNames: ''
>> >>     classVariableNames: ''
>> >>     poolDictionaries: ''
>> >>     category: 'Collections-Weak'
>> >>
>> >>
>> >>>
>> >>> This is because Pharo's WeakOrderedCollection is broken...
>> >>>
>> >>
>> >> Do you know a weak collection that is not broken in Pharo and let me do
>> >> a
>> >> addLast: ?
>> >>
>> >>>
>> >>> Every reference to Array from within OrderedCollection should be
>> >>> replaced with message send (self arrayType).
>> >>> See for example, OrderedCollection>>#grow
>> >>>
>> >>
>> >> Thanks. I will check how many there are and try to fix them.
>> >>
>> >>>
>> >>> Nicolas
>> >>>
>> >>> 2011/8/3 Mariano Martinez Peck <[hidden email]>:
>> >>> > Hi guys. I am since yesterday trying to find something and I cannot.
>> >>> > So
>> >>> > at
>> >>> > this point I need external eyes :)
>> >>> > I have this little code:
>> >>> >
>> >>> >     anObject := ClassWith2Var new.
>> >>> >     sharedObject := ClassWith1Var new.
>> >>> >     sharedObject var1: 'nose'.
>> >>> >     anObject var1: Date today.
>> >>> >     anObject var2: sharedObject.
>> >>> >
>> >>> >     serializedObjects := FuelMareaSerializer new
>> >>> > serializeAndWriteObject:
>> >>> > anObject to: 'aFileName'.
>> >>> >     anObject := nil.
>> >>> >     sharedObject := nil.
>> >>> >
>> >>> >     3 timesRepeat: [Smalltalk garbageCollect].
>> >>> >     serializedObjects inspect.
>> >>> >
>> >>> >
>> >>> >
>> >>> > What is important here is that FuelMareaSerializer new
>> >>> > serializeAndWriteObject: anObject to: 'aFileName' answers a
>> >>> > WeakOrderedCollection with each object of the serialized graph
>> >>> > (taking
>> >>> > anObject as the root)
>> >>> > Now, if I print the tempVar serializedObjects I see:
>> >>> >
>> >>> > a WeakOrderedCollection(ClassWith1Var ClassWith2Var Date DateAndTime
>> >>> > Duration a ClassWith1Var a ClassWith2Var 3 August 2011
>> >>> > 2011-08-03T00:00:00+02:00 0:02:00:00 1:00:00:00 86400 2455777 'nose'
>> >>> > 0
>> >>> > 7200)
>> >>> >
>> >>> > WHYYYY??  why are all there if I put a nil to both, anObject and
>> >>> > sharedObejct. This WeakOrderedCollection should be with all nils
>> >>> > (except
>> >>> > classes). Why are not being garbage collected?
>> >>> >
>> >>> > If I explore, for example the tempVar sharedObejct, which is at
>> >>> > serializedObjects at: 6   and then I put explore pointers I ONLY see
>> >>> > the
>> >>> > array of the WeakOrderedCollection pointing to it. I don't
>> >>> > understand.
>> >>> >
>> >>> > Any help is really appreaciated.
>> >>> >
>> >>> > --
>> >>> > Mariano
>> >>> > http://marianopeck.wordpress.com
>> >>> >
>> >>> >
>> >>>
>> >>
>> >>
>> >>
>> >> --
>> >> Mariano
>> >> http://marianopeck.wordpress.com
>> >>
>> >
>> >
>> >
>> > --
>> > Mariano
>> > http://marianopeck.wordpress.com
>> >
>> >
>>
>
>
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
>




--
Mariano
http://marianopeck.wordpress.com

Reply | Threaded
Open this post in threaded view
|

Re: Help with a WeakOrderedCollection and objects not being GCed

Mariano Martinez Peck
Ok, I have splitted the slice in two parts: PART1 and PART2. PART1 includes the fixes in #makeRoomAtFirst and #makeRoomAtLast and a new class WeakOrderedCollectionTest  with two tests: #testWeakOrderedCollectionSomeGarbageCollected and #testWeakOrderedCollectionAllGarbageCollected.

Those tests can be improved a lot and make them look like those in WeakSetTest where each collection operation is tested. I don't have the time/knowledge to do that right now, but if someone can, excellent.

The second part is just the revome of OrderedCollection >> grow.


Name: SLICE-Issue-4596-WeakOrderedColllection-array-is-replaced-by-an-Array-instead-of-a-WeakArray-PART1-MarianoMartinezPeck.1
Author: MarianoMartinezPeck
Time: 3 August 2011, 2:40:10 pm
UUID: 35f20200-98ef-581f-1100-000044ef581f
Ancestors: 
Dependencies: CollectionsTests-MarianoMartinezPeck.529, Collections-Sequenceable-MarianoMartinezPeck.97

This is the first part. It includes the fix and 2 tests.




Name: SLICE-Issue-4596-WeakOrderedColllection-array-is-replaced-by-an-Array-instead-of-a-WeakArray-PART2-MarianoMartinezPeck.1
Author: MarianoMartinezPeck
Time: 3 August 2011, 2:41:42 pm
UUID: caf00200-1007-401f-18ec-0e0008e05c1f
Ancestors: 
Dependencies: Collections-Sequenceable-MarianoMartinezPeck.98

It just removes OrderedCollection >> grow


On Wed, Aug 3, 2011 at 2:11 PM, Mariano Martinez Peck <[hidden email]> wrote:
Thanks a lot Nicolas and Henrik.  I have split the slice and it works!
I will upload soon both slides, part1 and part2 and a test for it.

On Wed, Aug 3, 2011 at 1:49 PM, Nicolas Cellier <[hidden email]> wrote:
Oh I see, for the SLICE, this is again the Pharo's version of
MCPackageLoader>>basicLoad which is striking.
In Squeak trunk it would work because removals are performed AFTER
methodAdditions/Changes.
In Pharo, removals are performed BEFORE, so yes, the SLICE needs to be
split in two parts...
Or you can just manually merge it (apply the removal after...).

I'm eager to see a true atomic load with a single massive becomeForward: :)
IMHO, this should be coupled with lazy initializations mechanism as I
proposed once (based on pragmas).

Now if you simply modify grow from within a browser, I see no obvious
reason why it would fail...

Nicolas

2011/8/3 Mariano Martinez Peck <[hidden email]>:
>
>
> On Wed, Aug 3, 2011 at 1:01 PM, Nicolas Cellier
> <[hidden email]> wrote:
>>
>> You replace Array with self arrayType, that's all.
>
> Here my images freezes and CPU goes 100%. I guess because compiling/saving a
> method uses OrderedCollection grow at the same time.
>
>>
>> But there is better, Pharo already has growAtFirst and growAtLast
>> which are correct.
>> Use them instead of grow.
>> See SLICE in inbox.
>
> I cannot load it since it freezes in "Cleaning Up". It can be the same
> reason as why I cannot save the modification.
> I am in Pharo1.3
> Latest update: #13277
>
> Thanks a lot for the help!
>
>>
>> Nicolas
>>
>> 2011/8/3 Mariano Martinez Peck <[hidden email]>:
>> > btw...how can I change OrderedCollection>>grow
>> > without shooting my foots?
>> >
>> > On Wed, Aug 3, 2011 at 12:51 PM, Mariano Martinez Peck
>> > <[hidden email]> wrote:
>> >>
>> >>
>> >> On Wed, Aug 3, 2011 at 12:42 PM, Nicolas Cellier
>> >> <[hidden email]> wrote:
>> >>>
>> >>> I'm pretty sure the array inst var of your WeakOrderedColleciton is no
>> >>> more a WeakArray but a simple Array.
>> >>
>> >> Yes, indeed, it is a normal Array and that cought my attention. But
>> >> since
>> >> I have no idea about Weak stuff...I also noticed that
>> >> WeakOrderedCollection
>> >> is declared as:
>> >>
>> >> OrderedCollection subclass: #WeakOrderedCollection
>> >>     instanceVariableNames: ''
>> >>     classVariableNames: ''
>> >>     poolDictionaries: ''
>> >>     category: 'Collections-Weak'
>> >>
>> >> instead of using the #weakSubclass: ... message:
>> >>
>> >> OrderedCollection weakSubclass: #WeakOrderedCollection
>> >>     instanceVariableNames: ''
>> >>     classVariableNames: ''
>> >>     poolDictionaries: ''
>> >>     category: 'Collections-Weak'
>> >>
>> >>
>> >>>
>> >>> This is because Pharo's WeakOrderedCollection is broken...
>> >>>
>> >>
>> >> Do you know a weak collection that is not broken in Pharo and let me do
>> >> a
>> >> addLast: ?
>> >>
>> >>>
>> >>> Every reference to Array from within OrderedCollection should be
>> >>> replaced with message send (self arrayType).
>> >>> See for example, OrderedCollection>>#grow
>> >>>
>> >>
>> >> Thanks. I will check how many there are and try to fix them.
>> >>
>> >>>
>> >>> Nicolas
>> >>>
>> >>> 2011/8/3 Mariano Martinez Peck <[hidden email]>:
>> >>> > Hi guys. I am since yesterday trying to find something and I cannot.
>> >>> > So
>> >>> > at
>> >>> > this point I need external eyes :)
>> >>> > I have this little code:
>> >>> >
>> >>> >     anObject := ClassWith2Var new.
>> >>> >     sharedObject := ClassWith1Var new.
>> >>> >     sharedObject var1: 'nose'.
>> >>> >     anObject var1: Date today.
>> >>> >     anObject var2: sharedObject.
>> >>> >
>> >>> >     serializedObjects := FuelMareaSerializer new
>> >>> > serializeAndWriteObject:
>> >>> > anObject to: 'aFileName'.
>> >>> >     anObject := nil.
>> >>> >     sharedObject := nil.
>> >>> >
>> >>> >     3 timesRepeat: [Smalltalk garbageCollect].
>> >>> >     serializedObjects inspect.
>> >>> >
>> >>> >
>> >>> >
>> >>> > What is important here is that FuelMareaSerializer new
>> >>> > serializeAndWriteObject: anObject to: 'aFileName' answers a
>> >>> > WeakOrderedCollection with each object of the serialized graph
>> >>> > (taking
>> >>> > anObject as the root)
>> >>> > Now, if I print the tempVar serializedObjects I see:
>> >>> >
>> >>> > a WeakOrderedCollection(ClassWith1Var ClassWith2Var Date DateAndTime
>> >>> > Duration a ClassWith1Var a ClassWith2Var 3 August 2011
>> >>> > 2011-08-03T00:00:00+02:00 0:02:00:00 1:00:00:00 86400 2455777 'nose'
>> >>> > 0
>> >>> > 7200)
>> >>> >
>> >>> > WHYYYY??  why are all there if I put a nil to both, anObject and
>> >>> > sharedObejct. This WeakOrderedCollection should be with all nils
>> >>> > (except
>> >>> > classes). Why are not being garbage collected?
>> >>> >
>> >>> > If I explore, for example the tempVar sharedObejct, which is at
>> >>> > serializedObjects at: 6   and then I put explore pointers I ONLY see
>> >>> > the
>> >>> > array of the WeakOrderedCollection pointing to it. I don't
>> >>> > understand.
>> >>> >
>> >>> > Any help is really appreaciated.
>> >>> >
>> >>> > --
>> >>> > Mariano
>> >>> > http://marianopeck.wordpress.com
>> >>> >
>> >>> >
>> >>>
>> >>
>> >>
>> >>
>> >> --
>> >> Mariano
>> >> http://marianopeck.wordpress.com
>> >>
>> >
>> >
>> >
>> > --
>> > Mariano
>> > http://marianopeck.wordpress.com
>> >
>> >
>>
>
>
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
>




--



--
Mariano
http://marianopeck.wordpress.com

Reply | Threaded
Open this post in threaded view
|

Re: Help with a WeakOrderedCollection and objects not being GCed

Stéphane Ducasse
In reply to this post by Nicolas Cellier
How can we test and make sure that in the future we know automatically if the weak is broken?

Stef

On Aug 3, 2011, at 1:01 PM, Nicolas Cellier wrote:

> You replace Array with self arrayType, that's all.
> But there is better, Pharo already has growAtFirst and growAtLast
> which are correct.
> Use them instead of grow.
> See SLICE in inbox.
>
> Nicolas
>
> 2011/8/3 Mariano Martinez Peck <[hidden email]>:
>> btw...how can I change OrderedCollection>>grow
>> without shooting my foots?
>>
>> On Wed, Aug 3, 2011 at 12:51 PM, Mariano Martinez Peck
>> <[hidden email]> wrote:
>>>
>>>
>>> On Wed, Aug 3, 2011 at 12:42 PM, Nicolas Cellier
>>> <[hidden email]> wrote:
>>>>
>>>> I'm pretty sure the array inst var of your WeakOrderedColleciton is no
>>>> more a WeakArray but a simple Array.
>>>
>>> Yes, indeed, it is a normal Array and that cought my attention. But since
>>> I have no idea about Weak stuff...I also noticed that WeakOrderedCollection
>>> is declared as:
>>>
>>> OrderedCollection subclass: #WeakOrderedCollection
>>>     instanceVariableNames: ''
>>>     classVariableNames: ''
>>>     poolDictionaries: ''
>>>     category: 'Collections-Weak'
>>>
>>> instead of using the #weakSubclass: ... message:
>>>
>>> OrderedCollection weakSubclass: #WeakOrderedCollection
>>>     instanceVariableNames: ''
>>>     classVariableNames: ''
>>>     poolDictionaries: ''
>>>     category: 'Collections-Weak'
>>>
>>>
>>>>
>>>> This is because Pharo's WeakOrderedCollection is broken...
>>>>
>>>
>>> Do you know a weak collection that is not broken in Pharo and let me do a
>>> addLast: ?
>>>
>>>>
>>>> Every reference to Array from within OrderedCollection should be
>>>> replaced with message send (self arrayType).
>>>> See for example, OrderedCollection>>#grow
>>>>
>>>
>>> Thanks. I will check how many there are and try to fix them.
>>>
>>>>
>>>> Nicolas
>>>>
>>>> 2011/8/3 Mariano Martinez Peck <[hidden email]>:
>>>>> Hi guys. I am since yesterday trying to find something and I cannot. So
>>>>> at
>>>>> this point I need external eyes :)
>>>>> I have this little code:
>>>>>
>>>>>     anObject := ClassWith2Var new.
>>>>>     sharedObject := ClassWith1Var new.
>>>>>     sharedObject var1: 'nose'.
>>>>>     anObject var1: Date today.
>>>>>     anObject var2: sharedObject.
>>>>>
>>>>>     serializedObjects := FuelMareaSerializer new
>>>>> serializeAndWriteObject:
>>>>> anObject to: 'aFileName'.
>>>>>     anObject := nil.
>>>>>     sharedObject := nil.
>>>>>
>>>>>     3 timesRepeat: [Smalltalk garbageCollect].
>>>>>     serializedObjects inspect.
>>>>>
>>>>>
>>>>>
>>>>> What is important here is that FuelMareaSerializer new
>>>>> serializeAndWriteObject: anObject to: 'aFileName' answers a
>>>>> WeakOrderedCollection with each object of the serialized graph (taking
>>>>> anObject as the root)
>>>>> Now, if I print the tempVar serializedObjects I see:
>>>>>
>>>>> a WeakOrderedCollection(ClassWith1Var ClassWith2Var Date DateAndTime
>>>>> Duration a ClassWith1Var a ClassWith2Var 3 August 2011
>>>>> 2011-08-03T00:00:00+02:00 0:02:00:00 1:00:00:00 86400 2455777 'nose' 0
>>>>> 7200)
>>>>>
>>>>> WHYYYY??  why are all there if I put a nil to both, anObject and
>>>>> sharedObejct. This WeakOrderedCollection should be with all nils
>>>>> (except
>>>>> classes). Why are not being garbage collected?
>>>>>
>>>>> If I explore, for example the tempVar sharedObejct, which is at
>>>>> serializedObjects at: 6   and then I put explore pointers I ONLY see
>>>>> the
>>>>> array of the WeakOrderedCollection pointing to it. I don't understand.
>>>>>
>>>>> Any help is really appreaciated.
>>>>>
>>>>> --
>>>>> Mariano
>>>>> http://marianopeck.wordpress.com
>>>>>
>>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Mariano
>>> http://marianopeck.wordpress.com
>>>
>>
>>
>>
>> --
>> Mariano
>> http://marianopeck.wordpress.com
>>
>>
>


Reply | Threaded
Open this post in threaded view
|

Re: Help with a WeakOrderedCollection and objects not being GCed

Stéphane Ducasse
In reply to this post by Nicolas Cellier

On Aug 3, 2011, at 1:49 PM, Nicolas Cellier wrote:

> Oh I see, for the SLICE, this is again the Pharo's version of
> MCPackageLoader>>basicLoad which is striking.
> In Squeak trunk it would work because removals are performed AFTER
> methodAdditions/Changes.
> In Pharo, removals are performed BEFORE, so yes, the SLICE needs to be
> split in two parts...
> Or you can just manually merge it (apply the removal after...).

oops we should fix that


> I'm eager to see a true atomic load with a single massive becomeForward: :)

Yes me too

> IMHO, this should be coupled with lazy initializations mechanism as I
> proposed once (based on pragmas).

Can you point us to that?


>
> Now if you simply modify grow from within a browser, I see no obvious
> reason why it would fail...
>
> Nicolas
>
> 2011/8/3 Mariano Martinez Peck <[hidden email]>:
>>
>>
>> On Wed, Aug 3, 2011 at 1:01 PM, Nicolas Cellier
>> <[hidden email]> wrote:
>>>
>>> You replace Array with self arrayType, that's all.
>>
>> Here my images freezes and CPU goes 100%. I guess because compiling/saving a
>> method uses OrderedCollection grow at the same time.
>>
>>>
>>> But there is better, Pharo already has growAtFirst and growAtLast
>>> which are correct.
>>> Use them instead of grow.
>>> See SLICE in inbox.
>>
>> I cannot load it since it freezes in "Cleaning Up". It can be the same
>> reason as why I cannot save the modification.
>> I am in Pharo1.3
>> Latest update: #13277
>>
>> Thanks a lot for the help!
>>
>>>
>>> Nicolas
>>>
>>> 2011/8/3 Mariano Martinez Peck <[hidden email]>:
>>>> btw...how can I change OrderedCollection>>grow
>>>> without shooting my foots?
>>>>
>>>> On Wed, Aug 3, 2011 at 12:51 PM, Mariano Martinez Peck
>>>> <[hidden email]> wrote:
>>>>>
>>>>>
>>>>> On Wed, Aug 3, 2011 at 12:42 PM, Nicolas Cellier
>>>>> <[hidden email]> wrote:
>>>>>>
>>>>>> I'm pretty sure the array inst var of your WeakOrderedColleciton is no
>>>>>> more a WeakArray but a simple Array.
>>>>>
>>>>> Yes, indeed, it is a normal Array and that cought my attention. But
>>>>> since
>>>>> I have no idea about Weak stuff...I also noticed that
>>>>> WeakOrderedCollection
>>>>> is declared as:
>>>>>
>>>>> OrderedCollection subclass: #WeakOrderedCollection
>>>>>     instanceVariableNames: ''
>>>>>     classVariableNames: ''
>>>>>     poolDictionaries: ''
>>>>>     category: 'Collections-Weak'
>>>>>
>>>>> instead of using the #weakSubclass: ... message:
>>>>>
>>>>> OrderedCollection weakSubclass: #WeakOrderedCollection
>>>>>     instanceVariableNames: ''
>>>>>     classVariableNames: ''
>>>>>     poolDictionaries: ''
>>>>>     category: 'Collections-Weak'
>>>>>
>>>>>
>>>>>>
>>>>>> This is because Pharo's WeakOrderedCollection is broken...
>>>>>>
>>>>>
>>>>> Do you know a weak collection that is not broken in Pharo and let me do
>>>>> a
>>>>> addLast: ?
>>>>>
>>>>>>
>>>>>> Every reference to Array from within OrderedCollection should be
>>>>>> replaced with message send (self arrayType).
>>>>>> See for example, OrderedCollection>>#grow
>>>>>>
>>>>>
>>>>> Thanks. I will check how many there are and try to fix them.
>>>>>
>>>>>>
>>>>>> Nicolas
>>>>>>
>>>>>> 2011/8/3 Mariano Martinez Peck <[hidden email]>:
>>>>>>> Hi guys. I am since yesterday trying to find something and I cannot.
>>>>>>> So
>>>>>>> at
>>>>>>> this point I need external eyes :)
>>>>>>> I have this little code:
>>>>>>>
>>>>>>>     anObject := ClassWith2Var new.
>>>>>>>     sharedObject := ClassWith1Var new.
>>>>>>>     sharedObject var1: 'nose'.
>>>>>>>     anObject var1: Date today.
>>>>>>>     anObject var2: sharedObject.
>>>>>>>
>>>>>>>     serializedObjects := FuelMareaSerializer new
>>>>>>> serializeAndWriteObject:
>>>>>>> anObject to: 'aFileName'.
>>>>>>>     anObject := nil.
>>>>>>>     sharedObject := nil.
>>>>>>>
>>>>>>>     3 timesRepeat: [Smalltalk garbageCollect].
>>>>>>>     serializedObjects inspect.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> What is important here is that FuelMareaSerializer new
>>>>>>> serializeAndWriteObject: anObject to: 'aFileName' answers a
>>>>>>> WeakOrderedCollection with each object of the serialized graph
>>>>>>> (taking
>>>>>>> anObject as the root)
>>>>>>> Now, if I print the tempVar serializedObjects I see:
>>>>>>>
>>>>>>> a WeakOrderedCollection(ClassWith1Var ClassWith2Var Date DateAndTime
>>>>>>> Duration a ClassWith1Var a ClassWith2Var 3 August 2011
>>>>>>> 2011-08-03T00:00:00+02:00 0:02:00:00 1:00:00:00 86400 2455777 'nose'
>>>>>>> 0
>>>>>>> 7200)
>>>>>>>
>>>>>>> WHYYYY??  why are all there if I put a nil to both, anObject and
>>>>>>> sharedObejct. This WeakOrderedCollection should be with all nils
>>>>>>> (except
>>>>>>> classes). Why are not being garbage collected?
>>>>>>>
>>>>>>> If I explore, for example the tempVar sharedObejct, which is at
>>>>>>> serializedObjects at: 6   and then I put explore pointers I ONLY see
>>>>>>> the
>>>>>>> array of the WeakOrderedCollection pointing to it. I don't
>>>>>>> understand.
>>>>>>>
>>>>>>> Any help is really appreaciated.
>>>>>>>
>>>>>>> --
>>>>>>> Mariano
>>>>>>> http://marianopeck.wordpress.com
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Mariano
>>>>> http://marianopeck.wordpress.com
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Mariano
>>>> http://marianopeck.wordpress.com
>>>>
>>>>
>>>
>>
>>
>>
>> --
>> Mariano
>> http://marianopeck.wordpress.com
>>
>>
>


Reply | Threaded
Open this post in threaded view
|

Re: Help with a WeakOrderedCollection and objects not being GCed

Mariano Martinez Peck
In reply to this post by Stéphane Ducasse


On Wed, Aug 3, 2011 at 10:27 PM, Stéphane Ducasse <[hidden email]> wrote:
How can we test and make sure that in the future we know automatically if the weak is broken?


If you check the issue traker, I've uploaded to tests for this case.
 
Stef

On Aug 3, 2011, at 1:01 PM, Nicolas Cellier wrote:

> You replace Array with self arrayType, that's all.
> But there is better, Pharo already has growAtFirst and growAtLast
> which are correct.
> Use them instead of grow.
> See SLICE in inbox.
>
> Nicolas
>
> 2011/8/3 Mariano Martinez Peck <[hidden email]>:
>> btw...how can I change OrderedCollection>>grow
>> without shooting my foots?
>>
>> On Wed, Aug 3, 2011 at 12:51 PM, Mariano Martinez Peck
>> <[hidden email]> wrote:
>>>
>>>
>>> On Wed, Aug 3, 2011 at 12:42 PM, Nicolas Cellier
>>> <[hidden email]> wrote:
>>>>
>>>> I'm pretty sure the array inst var of your WeakOrderedColleciton is no
>>>> more a WeakArray but a simple Array.
>>>
>>> Yes, indeed, it is a normal Array and that cought my attention. But since
>>> I have no idea about Weak stuff...I also noticed that WeakOrderedCollection
>>> is declared as:
>>>
>>> OrderedCollection subclass: #WeakOrderedCollection
>>>     instanceVariableNames: ''
>>>     classVariableNames: ''
>>>     poolDictionaries: ''
>>>     category: 'Collections-Weak'
>>>
>>> instead of using the #weakSubclass: ... message:
>>>
>>> OrderedCollection weakSubclass: #WeakOrderedCollection
>>>     instanceVariableNames: ''
>>>     classVariableNames: ''
>>>     poolDictionaries: ''
>>>     category: 'Collections-Weak'
>>>
>>>
>>>>
>>>> This is because Pharo's WeakOrderedCollection is broken...
>>>>
>>>
>>> Do you know a weak collection that is not broken in Pharo and let me do a
>>> addLast: ?
>>>
>>>>
>>>> Every reference to Array from within OrderedCollection should be
>>>> replaced with message send (self arrayType).
>>>> See for example, OrderedCollection>>#grow
>>>>
>>>
>>> Thanks. I will check how many there are and try to fix them.
>>>
>>>>
>>>> Nicolas
>>>>
>>>> 2011/8/3 Mariano Martinez Peck <[hidden email]>:
>>>>> Hi guys. I am since yesterday trying to find something and I cannot. So
>>>>> at
>>>>> this point I need external eyes :)
>>>>> I have this little code:
>>>>>
>>>>>     anObject := ClassWith2Var new.
>>>>>     sharedObject := ClassWith1Var new.
>>>>>     sharedObject var1: 'nose'.
>>>>>     anObject var1: Date today.
>>>>>     anObject var2: sharedObject.
>>>>>
>>>>>     serializedObjects := FuelMareaSerializer new
>>>>> serializeAndWriteObject:
>>>>> anObject to: 'aFileName'.
>>>>>     anObject := nil.
>>>>>     sharedObject := nil.
>>>>>
>>>>>     3 timesRepeat: [Smalltalk garbageCollect].
>>>>>     serializedObjects inspect.
>>>>>
>>>>>
>>>>>
>>>>> What is important here is that FuelMareaSerializer new
>>>>> serializeAndWriteObject: anObject to: 'aFileName' answers a
>>>>> WeakOrderedCollection with each object of the serialized graph (taking
>>>>> anObject as the root)
>>>>> Now, if I print the tempVar serializedObjects I see:
>>>>>
>>>>> a WeakOrderedCollection(ClassWith1Var ClassWith2Var Date DateAndTime
>>>>> Duration a ClassWith1Var a ClassWith2Var 3 August 2011
>>>>> 2011-08-03T00:00:00+02:00 0:02:00:00 1:00:00:00 86400 2455777 'nose' 0
>>>>> 7200)
>>>>>
>>>>> WHYYYY??  why are all there if I put a nil to both, anObject and
>>>>> sharedObejct. This WeakOrderedCollection should be with all nils
>>>>> (except
>>>>> classes). Why are not being garbage collected?
>>>>>
>>>>> If I explore, for example the tempVar sharedObejct, which is at
>>>>> serializedObjects at: 6   and then I put explore pointers I ONLY see
>>>>> the
>>>>> array of the WeakOrderedCollection pointing to it. I don't understand.
>>>>>
>>>>> Any help is really appreaciated.
>>>>>
>>>>> --
>>>>> Mariano
>>>>> http://marianopeck.wordpress.com
>>>>>
>>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Mariano
>>> http://marianopeck.wordpress.com
>>>
>>
>>
>>
>> --
>> Mariano
>> http://marianopeck.wordpress.com
>>
>>
>





--
Mariano
http://marianopeck.wordpress.com

Reply | Threaded
Open this post in threaded view
|

Re: Help with a WeakOrderedCollection and objects not being GCed

Stéphane Ducasse
In reply to this post by Mariano Martinez Peck
Thanks
I will have a look tomorrow morning, before packing to get back in the deep north (of France henrik).

On Aug 3, 2011, at 2:45 PM, Mariano Martinez Peck wrote:

> Ok, I have splitted the slice in two parts: PART1 and PART2. PART1 includes the fixes in #makeRoomAtFirst and #makeRoomAtLast and a new class WeakOrderedCollectionTest  with two tests: #testWeakOrderedCollectionSomeGarbageCollected and #testWeakOrderedCollectionAllGarbageCollected.
>
> Those tests can be improved a lot and make them look like those in WeakSetTest where each collection operation is tested. I don't have the time/knowledge to do that right now, but if someone can, excellent.
>
> The second part is just the revome of OrderedCollection >> grow.
>
>
> Name: SLICE-Issue-4596-WeakOrderedColllection-array-is-replaced-by-an-Array-instead-of-a-WeakArray-PART1-MarianoMartinezPeck.1
> Author: MarianoMartinezPeck
> Time: 3 August 2011, 2:40:10 pm
> UUID: 35f20200-98ef-581f-1100-000044ef581f
> Ancestors:
> Dependencies: CollectionsTests-MarianoMartinezPeck.529, Collections-Sequenceable-MarianoMartinezPeck.97
>
> This is the first part. It includes the fix and 2 tests.
>
>
>
>
> Name: SLICE-Issue-4596-WeakOrderedColllection-array-is-replaced-by-an-Array-instead-of-a-WeakArray-PART2-MarianoMartinezPeck.1
> Author: MarianoMartinezPeck
> Time: 3 August 2011, 2:41:42 pm
> UUID: caf00200-1007-401f-18ec-0e0008e05c1f
> Ancestors:
> Dependencies: Collections-Sequenceable-MarianoMartinezPeck.98
>
> It just removes OrderedCollection >> grow
>
>
>
> On Wed, Aug 3, 2011 at 2:11 PM, Mariano Martinez Peck <[hidden email]> wrote:
> Thanks a lot Nicolas and Henrik.  I have split the slice and it works!
> I will upload soon both slides, part1 and part2 and a test for it.
>
> On Wed, Aug 3, 2011 at 1:49 PM, Nicolas Cellier <[hidden email]> wrote:
> Oh I see, for the SLICE, this is again the Pharo's version of
> MCPackageLoader>>basicLoad which is striking.
> In Squeak trunk it would work because removals are performed AFTER
> methodAdditions/Changes.
> In Pharo, removals are performed BEFORE, so yes, the SLICE needs to be
> split in two parts...
> Or you can just manually merge it (apply the removal after...).
>
> I'm eager to see a true atomic load with a single massive becomeForward: :)
> IMHO, this should be coupled with lazy initializations mechanism as I
> proposed once (based on pragmas).
>
> Now if you simply modify grow from within a browser, I see no obvious
> reason why it would fail...
>
> Nicolas
>
> 2011/8/3 Mariano Martinez Peck <[hidden email]>:
> >
> >
> > On Wed, Aug 3, 2011 at 1:01 PM, Nicolas Cellier
> > <[hidden email]> wrote:
> >>
> >> You replace Array with self arrayType, that's all.
> >
> > Here my images freezes and CPU goes 100%. I guess because compiling/saving a
> > method uses OrderedCollection grow at the same time.
> >
> >>
> >> But there is better, Pharo already has growAtFirst and growAtLast
> >> which are correct.
> >> Use them instead of grow.
> >> See SLICE in inbox.
> >
> > I cannot load it since it freezes in "Cleaning Up". It can be the same
> > reason as why I cannot save the modification.
> > I am in Pharo1.3
> > Latest update: #13277
> >
> > Thanks a lot for the help!
> >
> >>
> >> Nicolas
> >>
> >> 2011/8/3 Mariano Martinez Peck <[hidden email]>:
> >> > btw...how can I change OrderedCollection>>grow
> >> > without shooting my foots?
> >> >
> >> > On Wed, Aug 3, 2011 at 12:51 PM, Mariano Martinez Peck
> >> > <[hidden email]> wrote:
> >> >>
> >> >>
> >> >> On Wed, Aug 3, 2011 at 12:42 PM, Nicolas Cellier
> >> >> <[hidden email]> wrote:
> >> >>>
> >> >>> I'm pretty sure the array inst var of your WeakOrderedColleciton is no
> >> >>> more a WeakArray but a simple Array.
> >> >>
> >> >> Yes, indeed, it is a normal Array and that cought my attention. But
> >> >> since
> >> >> I have no idea about Weak stuff...I also noticed that
> >> >> WeakOrderedCollection
> >> >> is declared as:
> >> >>
> >> >> OrderedCollection subclass: #WeakOrderedCollection
> >> >>     instanceVariableNames: ''
> >> >>     classVariableNames: ''
> >> >>     poolDictionaries: ''
> >> >>     category: 'Collections-Weak'
> >> >>
> >> >> instead of using the #weakSubclass: ... message:
> >> >>
> >> >> OrderedCollection weakSubclass: #WeakOrderedCollection
> >> >>     instanceVariableNames: ''
> >> >>     classVariableNames: ''
> >> >>     poolDictionaries: ''
> >> >>     category: 'Collections-Weak'
> >> >>
> >> >>
> >> >>>
> >> >>> This is because Pharo's WeakOrderedCollection is broken...
> >> >>>
> >> >>
> >> >> Do you know a weak collection that is not broken in Pharo and let me do
> >> >> a
> >> >> addLast: ?
> >> >>
> >> >>>
> >> >>> Every reference to Array from within OrderedCollection should be
> >> >>> replaced with message send (self arrayType).
> >> >>> See for example, OrderedCollection>>#grow
> >> >>>
> >> >>
> >> >> Thanks. I will check how many there are and try to fix them.
> >> >>
> >> >>>
> >> >>> Nicolas
> >> >>>
> >> >>> 2011/8/3 Mariano Martinez Peck <[hidden email]>:
> >> >>> > Hi guys. I am since yesterday trying to find something and I cannot.
> >> >>> > So
> >> >>> > at
> >> >>> > this point I need external eyes :)
> >> >>> > I have this little code:
> >> >>> >
> >> >>> >     anObject := ClassWith2Var new.
> >> >>> >     sharedObject := ClassWith1Var new.
> >> >>> >     sharedObject var1: 'nose'.
> >> >>> >     anObject var1: Date today.
> >> >>> >     anObject var2: sharedObject.
> >> >>> >
> >> >>> >     serializedObjects := FuelMareaSerializer new
> >> >>> > serializeAndWriteObject:
> >> >>> > anObject to: 'aFileName'.
> >> >>> >     anObject := nil.
> >> >>> >     sharedObject := nil.
> >> >>> >
> >> >>> >     3 timesRepeat: [Smalltalk garbageCollect].
> >> >>> >     serializedObjects inspect.
> >> >>> >
> >> >>> >
> >> >>> >
> >> >>> > What is important here is that FuelMareaSerializer new
> >> >>> > serializeAndWriteObject: anObject to: 'aFileName' answers a
> >> >>> > WeakOrderedCollection with each object of the serialized graph
> >> >>> > (taking
> >> >>> > anObject as the root)
> >> >>> > Now, if I print the tempVar serializedObjects I see:
> >> >>> >
> >> >>> > a WeakOrderedCollection(ClassWith1Var ClassWith2Var Date DateAndTime
> >> >>> > Duration a ClassWith1Var a ClassWith2Var 3 August 2011
> >> >>> > 2011-08-03T00:00:00+02:00 0:02:00:00 1:00:00:00 86400 2455777 'nose'
> >> >>> > 0
> >> >>> > 7200)
> >> >>> >
> >> >>> > WHYYYY??  why are all there if I put a nil to both, anObject and
> >> >>> > sharedObejct. This WeakOrderedCollection should be with all nils
> >> >>> > (except
> >> >>> > classes). Why are not being garbage collected?
> >> >>> >
> >> >>> > If I explore, for example the tempVar sharedObejct, which is at
> >> >>> > serializedObjects at: 6   and then I put explore pointers I ONLY see
> >> >>> > the
> >> >>> > array of the WeakOrderedCollection pointing to it. I don't
> >> >>> > understand.
> >> >>> >
> >> >>> > Any help is really appreaciated.
> >> >>> >
> >> >>> > --
> >> >>> > Mariano
> >> >>> > http://marianopeck.wordpress.com
> >> >>> >
> >> >>> >
> >> >>>
> >> >>
> >> >>
> >> >>
> >> >> --
> >> >> Mariano
> >> >> http://marianopeck.wordpress.com
> >> >>
> >> >
> >> >
> >> >
> >> > --
> >> > Mariano
> >> > http://marianopeck.wordpress.com
> >> >
> >> >
> >>
> >
> >
> >
> > --
> > Mariano
> > http://marianopeck.wordpress.com
> >
> >
>
>
>
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
>
>
>
> --
> Mariano
> http://marianopeck.wordpress.com
>


Reply | Threaded
Open this post in threaded view
|

Re: Help with a WeakOrderedCollection and objects not being GCed

Igor Stasenko
In reply to this post by Mariano Martinez Peck
On 3 August 2011 12:51, Mariano Martinez Peck <[hidden email]> wrote:

>
>
> On Wed, Aug 3, 2011 at 12:42 PM, Nicolas Cellier
> <[hidden email]> wrote:
>>
>> I'm pretty sure the array inst var of your WeakOrderedColleciton is no
>> more a WeakArray but a simple Array.
>
> Yes, indeed, it is a normal Array and that cought my attention. But since I
> have no idea about Weak stuff...I also noticed that WeakOrderedCollection is
> declared as:
>
> OrderedCollection subclass: #WeakOrderedCollection
>     instanceVariableNames: ''
>     classVariableNames: ''
>     poolDictionaries: ''
>     category: 'Collections-Weak'
>
> instead of using the #weakSubclass: ... message:
>
> OrderedCollection weakSubclass: #WeakOrderedCollection
>     instanceVariableNames: ''
>     classVariableNames: ''
>     poolDictionaries: ''
>     category: 'Collections-Weak'
>
no you don't need that, because ordered collection contains is
elements in its array,
and to make it 'weak' you have to make the container to hold elements weakly,
but not the wrapper class, which should hold it's array strongly.

>
>>
>> This is because Pharo's WeakOrderedCollection is broken...
>>
>
> Do you know a weak collection that is not broken in Pharo and let me do a
> addLast: ?
>
>>
>> Every reference to Array from within OrderedCollection should be
>> replaced with message send (self arrayType).
>> See for example, OrderedCollection>>#grow
>>
>
> Thanks. I will check how many there are and try to fix them.
>
>>
>> Nicolas
>>
>> 2011/8/3 Mariano Martinez Peck <[hidden email]>:
>> > Hi guys. I am since yesterday trying to find something and I cannot. So
>> > at
>> > this point I need external eyes :)
>> > I have this little code:
>> >
>> >     anObject := ClassWith2Var new.
>> >     sharedObject := ClassWith1Var new.
>> >     sharedObject var1: 'nose'.
>> >     anObject var1: Date today.
>> >     anObject var2: sharedObject.
>> >
>> >     serializedObjects := FuelMareaSerializer new
>> > serializeAndWriteObject:
>> > anObject to: 'aFileName'.
>> >     anObject := nil.
>> >     sharedObject := nil.
>> >
>> >     3 timesRepeat: [Smalltalk garbageCollect].
>> >     serializedObjects inspect.
>> >
>> >
>> >
>> > What is important here is that FuelMareaSerializer new
>> > serializeAndWriteObject: anObject to: 'aFileName' answers a
>> > WeakOrderedCollection with each object of the serialized graph (taking
>> > anObject as the root)
>> > Now, if I print the tempVar serializedObjects I see:
>> >
>> > a WeakOrderedCollection(ClassWith1Var ClassWith2Var Date DateAndTime
>> > Duration a ClassWith1Var a ClassWith2Var 3 August 2011
>> > 2011-08-03T00:00:00+02:00 0:02:00:00 1:00:00:00 86400 2455777 'nose' 0
>> > 7200)
>> >
>> > WHYYYY??  why are all there if I put a nil to both, anObject and
>> > sharedObejct. This WeakOrderedCollection should be with all nils (except
>> > classes). Why are not being garbage collected?
>> >
>> > If I explore, for example the tempVar sharedObejct, which is at
>> > serializedObjects at: 6   and then I put explore pointers I ONLY see the
>> > array of the WeakOrderedCollection pointing to it. I don't understand.
>> >
>> > Any help is really appreaciated.
>> >
>> > --
>> > Mariano
>> > http://marianopeck.wordpress.com
>> >
>> >
>>
>
>
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
>



--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

Re: Help with a WeakOrderedCollection and objects not being GCed

Igor Stasenko
In reply to this post by Stéphane Ducasse
On 3 August 2011 22:27, Stéphane Ducasse <[hidden email]> wrote:
> How can we test and make sure that in the future we know automatically if the weak is broken?
>

object := Object new.

coll := WeakOrderedCollection new add: anObject.
anObject := nil.
Smalltalk garbageCollect.
self assert: coll removeLast isNil

:)

> Stef
>
> On Aug 3, 2011, at 1:01 PM, Nicolas Cellier wrote:
>
>> You replace Array with self arrayType, that's all.
>> But there is better, Pharo already has growAtFirst and growAtLast
>> which are correct.
>> Use them instead of grow.
>> See SLICE in inbox.
>>
>> Nicolas
>>
>> 2011/8/3 Mariano Martinez Peck <[hidden email]>:
>>> btw...how can I change OrderedCollection>>grow
>>> without shooting my foots?
>>>
>>> On Wed, Aug 3, 2011 at 12:51 PM, Mariano Martinez Peck
>>> <[hidden email]> wrote:
>>>>
>>>>
>>>> On Wed, Aug 3, 2011 at 12:42 PM, Nicolas Cellier
>>>> <[hidden email]> wrote:
>>>>>
>>>>> I'm pretty sure the array inst var of your WeakOrderedColleciton is no
>>>>> more a WeakArray but a simple Array.
>>>>
>>>> Yes, indeed, it is a normal Array and that cought my attention. But since
>>>> I have no idea about Weak stuff...I also noticed that WeakOrderedCollection
>>>> is declared as:
>>>>
>>>> OrderedCollection subclass: #WeakOrderedCollection
>>>>     instanceVariableNames: ''
>>>>     classVariableNames: ''
>>>>     poolDictionaries: ''
>>>>     category: 'Collections-Weak'
>>>>
>>>> instead of using the #weakSubclass: ... message:
>>>>
>>>> OrderedCollection weakSubclass: #WeakOrderedCollection
>>>>     instanceVariableNames: ''
>>>>     classVariableNames: ''
>>>>     poolDictionaries: ''
>>>>     category: 'Collections-Weak'
>>>>
>>>>
>>>>>
>>>>> This is because Pharo's WeakOrderedCollection is broken...
>>>>>
>>>>
>>>> Do you know a weak collection that is not broken in Pharo and let me do a
>>>> addLast: ?
>>>>
>>>>>
>>>>> Every reference to Array from within OrderedCollection should be
>>>>> replaced with message send (self arrayType).
>>>>> See for example, OrderedCollection>>#grow
>>>>>
>>>>
>>>> Thanks. I will check how many there are and try to fix them.
>>>>
>>>>>
>>>>> Nicolas
>>>>>
>>>>> 2011/8/3 Mariano Martinez Peck <[hidden email]>:
>>>>>> Hi guys. I am since yesterday trying to find something and I cannot. So
>>>>>> at
>>>>>> this point I need external eyes :)
>>>>>> I have this little code:
>>>>>>
>>>>>>     anObject := ClassWith2Var new.
>>>>>>     sharedObject := ClassWith1Var new.
>>>>>>     sharedObject var1: 'nose'.
>>>>>>     anObject var1: Date today.
>>>>>>     anObject var2: sharedObject.
>>>>>>
>>>>>>     serializedObjects := FuelMareaSerializer new
>>>>>> serializeAndWriteObject:
>>>>>> anObject to: 'aFileName'.
>>>>>>     anObject := nil.
>>>>>>     sharedObject := nil.
>>>>>>
>>>>>>     3 timesRepeat: [Smalltalk garbageCollect].
>>>>>>     serializedObjects inspect.
>>>>>>
>>>>>>
>>>>>>
>>>>>> What is important here is that FuelMareaSerializer new
>>>>>> serializeAndWriteObject: anObject to: 'aFileName' answers a
>>>>>> WeakOrderedCollection with each object of the serialized graph (taking
>>>>>> anObject as the root)
>>>>>> Now, if I print the tempVar serializedObjects I see:
>>>>>>
>>>>>> a WeakOrderedCollection(ClassWith1Var ClassWith2Var Date DateAndTime
>>>>>> Duration a ClassWith1Var a ClassWith2Var 3 August 2011
>>>>>> 2011-08-03T00:00:00+02:00 0:02:00:00 1:00:00:00 86400 2455777 'nose' 0
>>>>>> 7200)
>>>>>>
>>>>>> WHYYYY??  why are all there if I put a nil to both, anObject and
>>>>>> sharedObejct. This WeakOrderedCollection should be with all nils
>>>>>> (except
>>>>>> classes). Why are not being garbage collected?
>>>>>>
>>>>>> If I explore, for example the tempVar sharedObejct, which is at
>>>>>> serializedObjects at: 6   and then I put explore pointers I ONLY see
>>>>>> the
>>>>>> array of the WeakOrderedCollection pointing to it. I don't understand.
>>>>>>
>>>>>> Any help is really appreaciated.
>>>>>>
>>>>>> --
>>>>>> Mariano
>>>>>> http://marianopeck.wordpress.com
>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Mariano
>>>> http://marianopeck.wordpress.com
>>>>
>>>
>>>
>>>
>>> --
>>> Mariano
>>> http://marianopeck.wordpress.com
>>>
>>>
>>
>
>
>



--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

Re: Help with a WeakOrderedCollection and objects not being GCed

Mariano Martinez Peck


On Wed, Aug 3, 2011 at 10:47 PM, Igor Stasenko <[hidden email]> wrote:
On 3 August 2011 22:27, Stéphane Ducasse <[hidden email]> wrote:
> How can we test and make sure that in the future we know automatically if the weak is broken?
>

object := Object new.

coll := WeakOrderedCollection new add: anObject.
anObject := nil.
Smalltalk garbageCollect.
self assert: coll removeLast isNil

That was not enought in this case. In fact, it was really difficult for me to find the bug, because it used to ONLY fail when sending #grow.

(WeakOrderedCollection new instVarNamed: 'array') class ->>>> WeakArray
 

(WeakOrderedCollection new grow instVarNamed: 'array') class  ->>>> Array

:)


:)

> Stef
>
> On Aug 3, 2011, at 1:01 PM, Nicolas Cellier wrote:
>
>> You replace Array with self arrayType, that's all.
>> But there is better, Pharo already has growAtFirst and growAtLast
>> which are correct.
>> Use them instead of grow.
>> See SLICE in inbox.
>>
>> Nicolas
>>
>> 2011/8/3 Mariano Martinez Peck <[hidden email]>:
>>> btw...how can I change OrderedCollection>>grow
>>> without shooting my foots?
>>>
>>> On Wed, Aug 3, 2011 at 12:51 PM, Mariano Martinez Peck
>>> <[hidden email]> wrote:
>>>>
>>>>
>>>> On Wed, Aug 3, 2011 at 12:42 PM, Nicolas Cellier
>>>> <[hidden email]> wrote:
>>>>>
>>>>> I'm pretty sure the array inst var of your WeakOrderedColleciton is no
>>>>> more a WeakArray but a simple Array.
>>>>
>>>> Yes, indeed, it is a normal Array and that cought my attention. But since
>>>> I have no idea about Weak stuff...I also noticed that WeakOrderedCollection
>>>> is declared as:
>>>>
>>>> OrderedCollection subclass: #WeakOrderedCollection
>>>>     instanceVariableNames: ''
>>>>     classVariableNames: ''
>>>>     poolDictionaries: ''
>>>>     category: 'Collections-Weak'
>>>>
>>>> instead of using the #weakSubclass: ... message:
>>>>
>>>> OrderedCollection weakSubclass: #WeakOrderedCollection
>>>>     instanceVariableNames: ''
>>>>     classVariableNames: ''
>>>>     poolDictionaries: ''
>>>>     category: 'Collections-Weak'
>>>>
>>>>
>>>>>
>>>>> This is because Pharo's WeakOrderedCollection is broken...
>>>>>
>>>>
>>>> Do you know a weak collection that is not broken in Pharo and let me do a
>>>> addLast: ?
>>>>
>>>>>
>>>>> Every reference to Array from within OrderedCollection should be
>>>>> replaced with message send (self arrayType).
>>>>> See for example, OrderedCollection>>#grow
>>>>>
>>>>
>>>> Thanks. I will check how many there are and try to fix them.
>>>>
>>>>>
>>>>> Nicolas
>>>>>
>>>>> 2011/8/3 Mariano Martinez Peck <[hidden email]>:
>>>>>> Hi guys. I am since yesterday trying to find something and I cannot. So
>>>>>> at
>>>>>> this point I need external eyes :)
>>>>>> I have this little code:
>>>>>>
>>>>>>     anObject := ClassWith2Var new.
>>>>>>     sharedObject := ClassWith1Var new.
>>>>>>     sharedObject var1: 'nose'.
>>>>>>     anObject var1: Date today.
>>>>>>     anObject var2: sharedObject.
>>>>>>
>>>>>>     serializedObjects := FuelMareaSerializer new
>>>>>> serializeAndWriteObject:
>>>>>> anObject to: 'aFileName'.
>>>>>>     anObject := nil.
>>>>>>     sharedObject := nil.
>>>>>>
>>>>>>     3 timesRepeat: [Smalltalk garbageCollect].
>>>>>>     serializedObjects inspect.
>>>>>>
>>>>>>
>>>>>>
>>>>>> What is important here is that FuelMareaSerializer new
>>>>>> serializeAndWriteObject: anObject to: 'aFileName' answers a
>>>>>> WeakOrderedCollection with each object of the serialized graph (taking
>>>>>> anObject as the root)
>>>>>> Now, if I print the tempVar serializedObjects I see:
>>>>>>
>>>>>> a WeakOrderedCollection(ClassWith1Var ClassWith2Var Date DateAndTime
>>>>>> Duration a ClassWith1Var a ClassWith2Var 3 August 2011
>>>>>> 2011-08-03T00:00:00+02:00 0:02:00:00 1:00:00:00 86400 2455777 'nose' 0
>>>>>> 7200)
>>>>>>
>>>>>> WHYYYY??  why are all there if I put a nil to both, anObject and
>>>>>> sharedObejct. This WeakOrderedCollection should be with all nils
>>>>>> (except
>>>>>> classes). Why are not being garbage collected?
>>>>>>
>>>>>> If I explore, for example the tempVar sharedObejct, which is at
>>>>>> serializedObjects at: 6   and then I put explore pointers I ONLY see
>>>>>> the
>>>>>> array of the WeakOrderedCollection pointing to it. I don't understand.
>>>>>>
>>>>>> Any help is really appreaciated.
>>>>>>
>>>>>> --
>>>>>> Mariano
>>>>>> http://marianopeck.wordpress.com
>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Mariano
>>>> http://marianopeck.wordpress.com
>>>>
>>>
>>>
>>>
>>> --
>>> Mariano
>>> http://marianopeck.wordpress.com
>>>
>>>
>>
>
>
>



--
Best regards,
Igor Stasenko AKA sig.




--
Mariano
http://marianopeck.wordpress.com