AIDA referencing my models, so they don't get collected

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

AIDA referencing my models, so they don't get collected

Facundo Ciccioli
Hi. Suppose I have my model (instance of Model), and its
WebApplication modelApp (instance of ModelApp, of course). Now, the
thing is that in my application, many times you create a Model, you
view it through its ModelApp, and then you forget about it. The model
would dissapear normaly, cause no one would be referencing it. But,
since I created a ModelApp for it, there are lots (apparently) of
references to it.

I guess my question is: is there a trivial way to solve this? Or I'll
have to see what all those references are and make my own way to
remove them?

Thanks a lot,
FaQ
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: AIDA referencing my models, so they don't get collected

Janko Mivšek
Hi Facundo,

Facundo Ciccioli pravi:

> Hi. Suppose I have my model (instance of Model), and its
> WebApplication modelApp (instance of ModelApp, of course). Now, the
> thing is that in my application, many times you create a Model, you
> view it through its ModelApp, and then you forget about it. The model
> would dissapear normaly, cause no one would be referencing it. But,
> since I created a ModelApp for it, there are lots (apparently) of
> references to it.
>
> I guess my question is: is there a trivial way to solve this? Or I'll
> have to see what all those references are and make my own way to
> remove them?

Aida is designed for permanent domain objects and not for short-living
ones. So you should try to redesign your model to have permanent objects
instead.

For short-lived objects (like results of SQL query) you can make a
special handling object, like Query and its QueryApp, and make it permanent.

But sometimes you need to delete a permanent domain object too. To
cleanup all Aida references to it, you need:

1. remove it from url resolver:

   self site urlResolver removeObject: anObject

2. remove it from session application state (WebSession instvar
appsForObjects). Don't do that imediatelly but leave to be done nightly by

   self site sessionManager nilAppsForObjects

..otherwise you'll delete the state for currently active users.

Then you still can't be sure that GC will finally remove your domain
object, but sooner or later it will. Session application state
(instances of your Apps) are namely stored on some more placed, which
got cleared after a while by itself (like WebSession lastApp).

'self site' can be called inside your App to get a reference to AIDASite
you are running on quickly.

I hope this helps a bit.
Janko


--
Janko Mivšek
AIDA/Web
Smalltalk Web Application Server
http://www.aidaweb.si
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: AIDA referencing my models, so they don't get collected

Herbert König
Hello Janko,


JM> Aida is designed for permanent domain objects and not for short-living
JM> ones. So you should try to redesign your model to have permanent objects
JM> instead.


JM>    self site sessionManager nilAppsForObjects

nilAppsForObjects is nowadays initAppsForObjects?

At least this got my apps collected while nilApps.. got a DNU.


Cheers

Herbert                            mailto:[hidden email]

_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Session Application State (was referencing my models...)

Janko Mivšek
Herbert König pravi:

> JM>    self site sessionManager nilAppsForObjects

> nilAppsForObjects is nowadays initAppsForObjects?

        WebSession>>initAppsForObjects
        WebSessionManager>>nilAppsForObjects

Well, a bit confusing. Maybe it is a time to rename them to more clear
message? like #clearApplicationState ?

Because in session's instvar #appsForObjects we have a dictionary with a
matrix of all instances of Apps for all objects on that session, which
is right to be called an application state, or session application
state, as part of overall session state.

What do you guys think?

Janko




--
Janko Mivšek
AIDA/Web
Smalltalk Web Application Server
http://www.aidaweb.si
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Session Application State (was referencing my models...)

Herbert König
Hello Janko,

        WebSession>>>initAppsForObjects
        WebSessionManager>>>nilAppsForObjects

JM> Well, a bit confusing. Maybe it is a time to rename them to more clear
JM> message? like #clearApplicationState ?

JM> Because in session's instvar #appsForObjects we have a dictionary with a
JM> matrix of all instances of Apps for all objects on that session, which
JM> is right to be called an application state, or session application
JM> state, as part of overall session state.

JM> What do you guys think?

yes that would have helped understanding and maybe even findig it
myself. But I confess that I personally (ab)use initialisation methods
for clearing the state of objects. At least when I do it I consider it
bad style, cause whenever I revisit that code later I ask myself why
that object hasn't been properly initialised earlier.


Cheers,

Herbert                            mailto:[hidden email]

_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida