Re: mod_perl and global %Live_Objects not being initialized

[prev] [thread] [next] [Date index for 2004/11/19]

From: Perrin Harkins
Subject: Re: mod_perl and global %Live_Objects not being initialized
Date: 03:22 on 19 Nov 2004
Andy Grundman wrote:
> Hmm, so if I did not have this kind of reference (which I must 
> somewhere), the Class::DBI object would be completely destroyed after 
> each request right?

Right.  It's a weak reference, so it doesn't prevent your objects from 
being garbage collected.

>> As stated above, it is not intended to be re-initialized on each
>> request.  It should last for the life of your program, regardless of
>> whether that program is mod_perl or a command-line script.
> 
> 
> I'm confused on what you mean by "life of your program".  In my case it 
> is lasting for the entire life of the Apache child, causing stale data 
> problems.  If my app was bug-free it would only last one request.  My 
> question is simply that if it is lasting for one request anyway, what's 
> the harm in initializing it to protect sloppy coders like me? :)

The harm is that there's no way for Class::DBI to know if you intended 
objects that don't get garbage-collected to go away.  You could be 
keeping them across requests on purpose.  Also, there's no easy way for 
us to make Class::DBI clear the index after each request, since it is 
independent of mod_perl and has no concept of when a request starts. 
Changing %Live_objects to a global wouldn't change this.

The simplest fix for scoping bugs is to turn off the Live_Objects 
feature, as described in previous posts on this list.  If you're 
confident that it only causes problems for you when a new request 
starts, you could put in a cleanup handler to clear the index after 
every request.  You may still have problems though, since you already 
know there are unsolved scoping bugs in there somewhere.

If you'd like help finding the scoping issue, you can post some minimal 
code here or on the mod_perl list and we can make some suggestions.

- Perrin

(message missing)

Re: mod_perl and global %Live_Objects not being initialized
Perrin Harkins 03:22 on 19 Nov 2004

Re: mod_perl and global %Live_Objects not being initialized
=?ISO-8859-1?Q?Ask_Bj=F8rn_Hansen?= 03:02 on 19 Nov 2004

Generated at 17:31 on 15 Feb 2005 by mariachi v0.52