Open
Description
I have used log4cplus version 2.0 as a static library in my VC++ project. I am using VS2013 on windows10 my project is 32bit.
Here is snippet of my initialization code.
std::wstring wsLogFileName = mb_to_wstring(strLogFile);
auto primaryAppender = new log4cplus::RollingFileAppender(wsLogFileName, 10 * 1024 * 1024, 5);
log4cplus::SharedAppenderPtr fileAppender = log4cplus::SharedAppenderPtr(primaryAppender);
auto pLayout = new log4cplus::PatternLayout(LOG4CPLUS_TEXT("%D{%m-%d-%y %H:%M:%S.%q} [%5t] %-5p %m%n"));
std::auto_ptr<log4cplus::Layout> layout(pLayout);
fileAppender->setLayout(layout);
logger.addAppender(fileAppender);
log4cplus::SharedAppenderPtr debugAppender(new log4cplus::Win32DebugAppender());
std::auto_ptr<log4cplus::Layout> layout2(new log4cplus::TTCCLayout());
debugAppender->setLayout(layout2);
logger.addAppender(debugAppender);
My Application is multithreaded but the global singleton instance of the logger is used throughout the application. As the application starts running, the memory consumption starts accumulating. If the application is kept running for long duration the application crashes due to memory consumption. The method threadCleanup(); is called when my application is closed. gfalgs tool also shows the memory leak where log4cplus methods are called for logging the messages.
Please suggest me the changes needed to be done to resolve this issue.