-
Notifications
You must be signed in to change notification settings - Fork 66
Description
I was poking around inside the guts of Log::Log4perl and noticed this:
sub cleanup {
# Delete all loggers
foreach my $loggername (keys %$LOGGERS_BY_NAME) {
$LOGGERS_BY_NAME->{$loggername}->DESTROY();
delete $LOGGERS_BY_NAME->{$loggername};
}
The explicit call to DESTROY strikes me as an overly aggressive cleanup. If the logger is no longer in use, no longer referenced elsewhere, DESTROY will be called automatically when it's deleted from %LOGGERS_BY_NAME
. If the logger IS still referenced, then some code somewhere is left with a busted logger object.
This makes cleanup
unusable for long running processes to clean out the cache of unused loggers. See http://stackoverflow.com/questions/5914088/disposing-of-log4perl-logger-when-i-no-longer-need-it
Is there another reason for this? Perhaps to break a circular reference? It was added in 079329e but no rationale is given.
Since Log::Log4perl::Logger->cleanup
is undocumented, and its only use is in an END block, and all it does is disassemble some hashes and call DESTROY on some objects that are about to be destroyed anyway... why does it exist at all?
In a related note, Log::Log4perl::Logger->DESTROY
doesn't appear to do anything useful. It deletes things that will be automatically cleaned up in object destruction. Is that circular reference defense?