I'm debugging some memory leaks in a daemon process of mine and came across an issue with subclassing from LogImpl. Not sure if i'm doing something i shouldn't or if there is a better way, but basically LogImpl subscribes to event and never unsubscribes, making the repository hold on to my logging objects forever.

The problem seems to be this:

       public LogImpl(ILogger logger) : base(logger)
       {
           // Listen for changes to the repository
logger.Repository.ConfigurationChanged += new LoggerRepositoryConfigurationChangedEventHandler(LoggerRepositoryConfigurationChanged);

           // load the current levels
           ReloadLevels(logger.Repository);
       }

There is no matching -= for logger.Repository.ConfigurationChanged and since LoggerRepositoryConfigurationChanged is private no way i can do it by hand.

The reason i created a logger based on LogImpl is that i wanted to create a logger that always prepends some context specific data to every log message. Is there a better way to do this without creating my subclass or if subclassing is the right way to go, is there something else i should be doing to not get this perpetual reference?

thanks
Arne Claassen

Reply via email to