lfiedler
10/14/2004 8:56:00 PM
I have a few questions on how to make sure remoted objects leases don't
expire when they are needed, but also are garbage collected when not needed
anymore. I believe I have a solution, but would like others' opinions and
solutions.
Basically, in my programming model, any node that remotes an object will
keep a reference to that object until the clients are done w/ it and until
the node is done w/ it. When all references are removed, it's up for
garbage collection. So, to make sure the lease on life doesn't expire on
these remoted objects, I was going to extend the marshalbyrefobject class
have a sponsor associated w/ it. When the sponsor gets notified that the
lease on life is going to expire and the KILL flag isn't set just add time
to it. When the reference to the remoted object in the serving node is
removed, a kill() method on the object is also called, setting the KILL
flag.
So the kill method kindof acts like the delete keyword in c++, only that the
memory isn't freed until the lease on life expires and until the garbage
collection gets it. So, it really doesn't act like it, but the programmers
call kill like delete.
But, this brings up a point, if a programmer doesn't call the kill() method,
then the object will live forever - thus introducing possible memory leaks.
So what's the point in having all this nice garbage collection stuff if you
can still have memory leaks?