You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by jasantunes <ja...@gmail.com> on 2015/08/26 03:59:07 UTC

deallocating resources

Hi!

Every time we create a logger "instance" it allocates resources, such as:


Obviously, the pointer destructors won't release the logger. But is there a
way to deallocate resources for a particular logger?
Something like /Logger::releaseLogger("aaa")/, which would release logger
"aaa" or even /Logger::releaseLogger("bbb")/, which would release the
loggers "bbb.xxx" and "bbb.yyy"?

Thanks



-----
Joao Antunes
--
View this message in context: http://apache-logging.6191.n7.nabble.com/deallocating-resources-tp57071.html
Sent from the Log4cxx - Users mailing list archive at Nabble.com.

Re: deallocating resources

Posted by Thorsten Schöning <ts...@am-soft.de>.
Guten Tag jasantunes,
am Mittwoch, 26. August 2015 um 03:59 schrieben Sie:

> Every time we create a logger "instance" it allocates resources, such as:

Your example is missing here, but in general you shouldn't create
Logger instances on your own, but retrieve them using
Logger::getLogger which will take care on creating new instances and
such using an underlying LoggerRepository as maintainig container.

> Obviously, the pointer destructors won't release the logger. But is there a
> way to deallocate resources for a particular logger?

No, you would need to implement a LoggerRepository and Hierarchy to do
that on your own, which I doubt is worth the amount of work. From the
docs:

> The hierarchy is such that children link to their parent but parents
> do not have any pointers to their children.

https://logging.apache.org/log4cxx/apidocs/classlog4cxx_1_1_hierarchy.html
https://logging.apache.org/log4cxx/apidocs/classlog4cxx_1_1spi_1_1_logger_repository.html

So in your example Logger "aaa" or "bbb" don't know anything about
their children, so you can't free them currently because you don't
know if they have children or not. Additionally, loggers are often
used statically, so they have no useful scope to release them. You use
case doesn't seem to be very common.

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning       E-Mail: Thorsten.Schoening@AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow