logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From deepak singh <deepak.i...@gmail.com>
Subject Re: How to clean up the log4cxx objects to avoid the memory leak?
Date Wed, 14 Oct 2009 05:20:22 GMT
You should use smart pointer instead.
e.g

    log4cxx::LogManager::resetConfiguration();
   log4cxx::LayoutPtr layoutPtr(new log4cxx::PatternLayout("%c-%p
(%d{dd MMM yyyy HH:mm:ss}) [%-5t] %m%n"));
   log4cxx::AppenderPtr appenderPtr( new
log4cxx::ConsoleAppender(layoutPtr, "System.err"));
   log4cxx::BasicConfigurator::configure(appenderPtr);

Thanks
Deepak

On Wed, Oct 14, 2009 at 8:41 AM, Zhou Tao <zhoutao109@gmail.com> wrote:

> Experts,
>
> I am using the log4cxx-0.10.0. And at the begining of the application, I
> create the log4cxx instances including Logger, FileAppender, PatternLayout
> etc. Sometime within the application, I need to destroy the instances.
> For example,
> To create the below objects at the begining,
>
> _layout = new log4cxx::PatternLayout(format);
> _fileAppender = new log4cxx::RollingFileAppender();
> ....
>
> Then somewhere to remove the above objects like the below,
>
> delete _fileAppender;
> delete _layout;
> ....
>
> However when deleting the objects, always core dump on windows. On unix,
> when the application exit, also get a core dump.
> Then how to clean up the log4cxx instances or a sequence is required when
> deleting the objects? or some example code?
>
> Any suggestion are highly appreciated.
> Thanks,
> Tom
>

Mime
View raw message