Re: Is garbage collection here yet?
- From: "Sean Woods" <yoda@xxxxxxxxxx>
- Date: 24 Apr 2006 06:55:25 -0700
I've been writing an object-oriented web framework for tclhttpd for the
past 8 years.
I have actually toyed with many arrangements. If you make garbage
collection on
by default you can have key subsystems like database drivers or table
handlers
either die horribly, or they system requires so many "invitations to
make a reservation"
that it slows to a crawl.
By that I mean instead of referencing the object directly, one instead
calls a function
that either locates the object in memory or creates it on the fly. Well
in TCL it crawls.
Trust me, I've tried it. I'll be happy to provide some example code.
But take my word
for it, it is a blind alley.
The archtecture that seems to balance the ease of garbage collection
while not forcing
EVERYTHING to be a reference call is a strategy I lovingly call
"curbside collection."
In "curbside collection", if an object should be cleaned up when idle
it (or it's container
object) "register" the object with a central collection mechanism. All
calls to this
node are never direct, but instead are made by asking the container
object for its
wherabouts. If the object already exists, the container passes back a
reference. If
not, it creates the node, stuffs it with data, and then returns the
reference. Inside
the "reference" call of the container is a call to the central
collector that "touches"
the node. Essentially says "hey, I used it" with a time stamp.
In the background of the application is a scripts that continually runs
and checks
through all of the objects that have been registered. The system checks
for the
time stamp of the last use, and if the time difference is greater than
a threshold.
the object is put on the curb.
At the end of the poll, all of the objects on the curb are destroyed.
I use it as a poor man's caching mechanism for objects that represent
database
records. (Databases with thousands of records, I might add.) Because
they
are somewhat expensive to create and destroy, I try to keep them in
memory
if they are under constant use.
Well, that's my experience. I will be happy to discuss the technical
details
if anyone has an interest.
.
- Follow-Ups:
- Re: Is garbage collection here yet?
- From: Fredderic
- Re: Is garbage collection here yet?
- References:
- Re: Is garbage collection here yet?
- From: Fredderic
- Re: Is garbage collection here yet?
- Prev by Date: Re: Anybody can provide me libmysql.so and mysqltcl.so
- Next by Date: Re: Dr. Dobb's Tcl-URL!
- Previous by thread: Re: Is garbage collection here yet?
- Next by thread: Re: Is garbage collection here yet?
- Index(es):
Relevant Pages
|
|