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

Janko Mivšek janko.mivsek at eranova.si
Fri Jan 30 14:09:26 CET 2009


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


More information about the Aida mailing list