From: Mike S. <m...@pe...> - 2004-06-01 07:03:34
|
Kevin Goess wrote on 5/29/2004, 11:08 PM: > First, did you actually track down the circular reference the Logger.pm > mentioned? Maybe I'm being dense (probably) but I don't see it in the > dump you sent. I checked out a basic $logger under use > Test::Memory::Cycle and didn't see any circular references. Hmm, you could be on to someting: Maybe the reason why the loggers aren't cleaned up correctly isn't circular references, it's simply that there's still references lurking around. They can be held by package variables like $Log::Log4perl::Logger::ROOT_LOGGER and also by non-lexical variables which have obtained a logger instance in the main program: no strict; $logger = get_logger("Foo"); # Not a "my" variable On the other hand, if there's no circular reference, why does something like the following leak memory? use Log::Log4perl qw(get_logger); while(1) { Log::Log4perl->init(\ q{ log4perl.logger = DEBUG, A1 log4perl.appender.A1 = Log::Log4perl::Appender::Screen log4perl.appender.A1.layout = SimpleLayout }); $logger = get_logger("foo"); } > So the Mail appender's DESTROY is being called during the Global > Destruction phase and overwriting $?. Maybe what we need to do is > "local($?)" before then--if we can localize $? in the call stack above > where the flush() happens then the correct value will be restored after > the flush completes, right? I'm not sure if you can localize $? while the GDP happens. > ~ However, your (Mike's) example sets $? in that BEGIN block, but doesn't > help Tim's code, his $? isn't from a BEGIN block. Hmm, I didn't use a BEGIN block -- not sure I'm following. > However, if you change > END { Log::Log4perl::Logger::cleanup(); } > to > END { local($?); Log::Log4perl::Logger::cleanup(); } > Then Tim's code does finish with the proper exit strategy. Didn't my patch work with Tim's code? I added END { $? = 255 } to Tim's snippet and it exited correctly with 255. Guess we need to talk more about this, unfortunately, it's too late today for non-nocturnals ... :) -- -- Mike Mike Schilli m...@pe... |