Menu

#89 Memoryleak using configuration file

closed
None
5
2009-12-30
2009-12-29
No

Hallo,

I am using log4cplus with a configuration file.
At the entry-point of my program I write:

PropertyConfigurator::doConfigure("log4cplus.properties");

In every cpp-file I define a static logger like this:

#include <log4cplus/logger.h>
#include <log4cplus/fileappender.h>
#include <log4cplus/loglevel.h>
#include <log4cplus/configurator.h>

using namespace log4cplus;
using namespace log4cplus::helper

Logger static logger = Logger::getInstance("myfilename.cpp");

And then I use the logging mechanisms:

LOG4CPLUS_DEBUG(logger, "My Message");

When finishing my Program, the Memory leak detector points to a lot of memory leaks. Most of them are coused by the line at the entry-point of my Programm:

PropertyConfigurator::doConfigure("log4cplus.properties");

Also some are caused by the Line:

Logger static logger = Logger::getInstance("myfilename.cpp");

Is there a bug, or do I use log4cplus in a wrong way?

Thanks, Anton

Discussion

  • Václav Haisman

    Václav Haisman - 2009-12-29
    • assigned_to: nobody --> wilx
     
  • Václav Haisman

    Václav Haisman - 2009-12-29

    Hi.

    There should not be any significant memory leaks in log4cplus. There were some minor leaks in 1.0.3 but those are fixed now.

    There are some static variables holding dynamically allocated memory which seems to be considered as memory leak by some memory leak detectors. However even those are destroyed and the memory is freed at the time static variables are destroyed.

    Unless the seemingly leaking memory increases during the run time of your application, or unless the amount is huge I would not worry much about it.

     
  • Anton  Heidelwalder

    hi wilx,

    thanks; I will use it that way!
    You are right , I couldn't find acummulating memory leaks. There was always displayed the same number of 56 leaks.

    Anton

     
  • Václav Haisman

    Václav Haisman - 2009-12-30
    • status: open --> closed
     

Log in to post a comment.