[Seaside] Object Instances / Garbage collection

Dmitri Zagidulin dmitri at zagidulin.net
Thu Aug 31 19:59:14 UTC 2006


Avi:
I tried clearing the session cache amd forcing garbage collect. That helps
only a part of the way. There's something else I'm missing.

Ramon:
I agree with your general point, that this is an issue of approach more than
anything.
Just like you said, I'm using a collection to keep track of the items. But
after they're deleted from the collection,
they're still persisting, and accumulating.

Which leads me to suspect I'm missing something, some kind of references
that I'm not releasing to them.
Is there any way to discover which objects are pointing to a particular
instance?

And in general, is there no other way to "release" an object for garbage
collecting, other than making sure there are no references to it?

On 8/31/06, Ramon Leon <ramon.leon at allresnet.com> wrote:
>
> > I suspect this might be a general Squeak question, but I want
> > to ask it here in case Seaside adds some complications or
> > things to consider:
> >
> > How do I delete object instances (is forcing garbage collection
> > involved) from the image?
> >
> > So, for instance, say I have a simple Shopping Cart and Items
> > sort of setup.
> > I add several Items to the cart, which creates instances of
> > those objects.
> >
> > And then I want to remove them from the cart, delete them.
> > But they're still around in the image, inspecting Item
> > allInstances still reveals those items which are no longer in
> > the cart.
> >
> > This sort of thing happens all the time in my web apps (I'm
> > using the simplest form of persistence - in image, no
> > database or anything, while prototyping), and I'm wondering
> > how you guys get around that.
> >
> > ~Dmitri
>
> You shouldn't really force gc or flush the session caches, you really just
> need to change your mindset.  Once you remove them from the cart, forget
> about them, they're gone, they'll be gc'd eventually.  Don't use SomeClass
>
> allInstances as if it were a database, it's not.  If you want to keep
> track
> of all of your carts, or items, or whatever, put them in your own
> collection
> or dictionary somewhere, so that when you remove them, they are
> effectively
> deleted.  If you want in image persistence, try something like adding an
> accessor on the class side like..
>
> Order class>>allOrders
>     ^allOrders ifNil: [allOrders := Dictionary new]
>
> Then you can do stuff like
>
> Transcript show: (Order allOrders at: someId)
>
> Order allOrders do:[:each |
>   html text: each asString; break].
>
> Try to forget about the concept of delete, that's a relational concept, it
> doesn't really exist in OO.  With transparent persistence, an object is
> either referenced, or it isn't, that's all you have to think about.  If
> you
> want to save an object, just put it somewhere like
>
> Order allOrders at: someId put: Order new.
>
> Now it's saved.  If you want to get rid of it, then remove it
>
> Order allOrders removeKey: someId
>
> Or
>
> Order allOrders remove: anOrder
>
> That's it, it's gone.  Don't worry that a transient reference might hang
> around for a while, you shouldn't care, it's been removed from your model.
>
>
> Or maybe you want to consider you SeasideSession as a database, put stuff
> on
> the class side
>
> MySession>>allOrders
>     ^self class allOrders
>
> MySession class>>allOrders
>     ^allOrders ifNil: [allOrders := Dictionary new]
>
> MySession>>allCustomers
>     ^self class allCustomers
>
> MySession class>>allCustomers
>     ^allCustomers ifNil: [allCustomers := Dictionary new]
>
> Then from you code it's
>
> self session allOrders, or self session allCustomers.  Just a couple
> simple
> ideas.
>
> _______________________________________________
> Seaside mailing list
> Seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20060831/facf8e63/attachment-0001.htm


More information about the Seaside mailing list