Object Destruction (or how to destroy instance)

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

Object Destruction (or how to destroy instance)

Oleg Richards
Hello Guys!

Maybe this question is more about smalltalk than about seaside, so  
i'm sorry.

In my reporting application i have following problem:
Some components of my seaside application working with Business Model  
copies.
I do it to have ability to revert changes. If user wants to save  
changes, database collection
just replaces old business objects with their updated copies. So  
everything works just fine.

But there is a question: If i ask VisualWorks to show all instances  
of Business Model, i can also
see old models, which were replaced by newer ones in DB collections.  
So some instances "just flying
in the air". How can i destroy them (something like calling  
destructor in C++). Or thats a not a problem and
they will be killed by garbage collector sometime? If so, when they  
will be killed?

Cheers, Oleg
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Object Destruction (or how to destroy instance)

Boris Popov, DeepCove Labs (SNN)
Re: [Seaside] Object Destruction (or how to destroy instance)

Inspect those instances and lookup refrences to them via the menu bar. They will be collected only if no one has a hard reference to them.

Cheers!

-Boris
(Sent from a BlackBerry)

----- Original Message -----
From: [hidden email] <[hidden email]>
To: [hidden email] <[hidden email]>
Sent: Wed Sep 12 01:43:01 2007
Subject: [Seaside] Object Destruction (or how to destroy instance)

Hello Guys!

Maybe this question is more about smalltalk than about seaside, so 
i'm sorry.

In my reporting application i have following problem:
Some components of my seaside application working with Business Model 
copies.
I do it to have ability to revert changes. If user wants to save 
changes, database collection
just replaces old business objects with their updated copies. So 
everything works just fine.

But there is a question: If i ask VisualWorks to show all instances 
of Business Model, i can also
see old models, which were replaced by newer ones in DB collections. 
So some instances "just flying
in the air". How can i destroy them (something like calling 
destructor in C++). Or thats a not a problem and
they will be killed by garbage collector sometime? If so, when they 
will be killed?

Cheers, Oleg
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: Object Destruction (or how to destroy instance)

Sebastian Sastre-2
In reply to this post by Oleg Richards

> -----Mensaje original-----
> De: [hidden email]
> [mailto:[hidden email]] En nombre
> de Oleg Richards
> Enviado el: MiƩrcoles, 12 de Septiembre de 2007 05:43
> Para: [hidden email]
> Asunto: [Seaside] Object Destruction (or how to destroy instance)
>
> Hello Guys!
>
> Maybe this question is more about smalltalk than about
> seaside, so i'm sorry.
>
> In my reporting application i have following problem:
> Some components of my seaside application working with
> Business Model copies.
> I do it to have ability to revert changes. If user wants to
> save changes, database collection just replaces old business
> objects with their updated copies. So everything works just fine.
>
> But there is a question: If i ask VisualWorks to show all
> instances of Business Model, i can also see old models, which
> were replaced by newer ones in DB collections.  
> So some instances "just flying
> in the air". How can i destroy them (something like calling
> destructor in C++). Or thats a not a problem and they will be
> killed by garbage collector sometime? If so, when they will be killed?
>
> Cheers, Oleg

Probably the instances are not that *in the air* as you may think. This
could happen if at least one object has direct references to them (or a root
of the graph of them). Make a double check to see if you really make them
nobody knows them anymore. The rest of the work is garbage collectors magic,

Cheers,

Sebastian

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Object Destruction (or how to destroy instance)

Oleg Richards
In reply to this post by Oleg Richards
Hello!

I've tried some of your recommendations, but after analyzing
owners of BusinessObject's in WeakArray (from query all class  
instances).

I see some references: They are referenced by some Seaside components.
But for now only one component is active. System doesn't have another  
components.
They are only called from root task or from some callbacks of anchors  
with: call: (SOReportTable new: aReport).

Code looks like that:


|myAnswer|
myAnswer := self call: (SOReportTable new: report copy).
myAnswer ifNotNil: [ report := myAnswer ]
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: Re: Object Destruction (or how to destroy instance)

Sebastian Sastre-2
Well garbage collection does not make differences between objects. Or they
are in use (referenced by other no matter who) or they not. There resides
it's discern.

I don't know what do you mean by "active" components or non active ones, but
if any object know another no matter what, the system guarantees you that it
will not be reclaimed by GC.

        cheers,

Sebastian Sastre


> -----Mensaje original-----
> De: [hidden email]
> [mailto:[hidden email]] En nombre
> de Oleg Richards
> Enviado el: MiƩrcoles, 12 de Septiembre de 2007 14:05
> Para: [hidden email]
> Asunto: [Seaside] Re: Object Destruction (or how to destroy instance)
>
> Hello!
>
> I've tried some of your recommendations, but after analyzing
> owners of BusinessObject's in WeakArray (from query all class
> instances).
>
> I see some references: They are referenced by some Seaside components.
> But for now only one component is active. System doesn't have
> another components.
> They are only called from root task or from some callbacks of anchors
> with: call: (SOReportTable new: aReport).
>
> Code looks like that:
>
>
> |myAnswer|
> myAnswer := self call: (SOReportTable new: report copy).
> myAnswer ifNotNil: [ report := myAnswer ]
> _______________________________________________
> Seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Object Destruction (or how to destroy instance)

Oleg Richards
In reply to this post by Oleg Richards
I understand. Active components - components that i have on my screen..

Others was used in call.. And now they returned answer and i think  
that they are not active.
But they still have link to report, which they returned via answer.
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Re: Object Destruction (or how to destroy instance)

Lukas Renggli
> Others was used in call.. And now they returned answer and i think
> that they are not active.
> But they still have link to report, which they returned via answer.

Inactive components don't immediately disappear from the
object-memory. The user of your application might hit the back button
anytime and then the state of the component tree needs to be restored.
Components that are not visible anymore will eventually be garbage
collected, either after a couple of requests (~10) or at session
timeout.

Cheers,
Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Object Destruction (or how to destroy instance)

Oleg Richards
In reply to this post by Oleg Richards
I think, that they are still alive, because of WAStateHolder.
If system remembers each state it also should remember all variables  
for this step.

But when it will be cleared?
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside