Skip to content

Commit

Permalink
Release memory at exit when LogManager::shutdown is not called
Browse files Browse the repository at this point in the history
  • Loading branch information
stephen-webb committed Dec 20, 2024
1 parent e227b5c commit e8c656a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/main/cpp/aprinitializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ APRInitializer::APRInitializer() :

APRInitializer::~APRInitializer()
{
deleteWatchDogs();
isDestructed = true;
#if APR_HAS_THREADS
std::lock_guard<std::mutex> lock(m_priv->mutex);
Expand Down
8 changes: 2 additions & 6 deletions src/main/cpp/filewatchdog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,7 @@ bool FileWatchdog::is_active()

void FileWatchdog::stop()
{
if (is_active())
{
LogLog::debug(LOG4CXX_STR("Stopping file watchdog"));
ThreadUtility::instance()->removePeriodicTask(m_priv->taskName);
}
ThreadUtility::instance()->removePeriodicTask(m_priv->taskName);
}

/**
Expand Down Expand Up @@ -134,8 +130,8 @@ void FileWatchdog::checkAndConfigure()

void FileWatchdog::start()
{
checkAndConfigure();
auto p = ThreadUtility::instance();
checkAndConfigure();
if (!p->hasPeriodicTask(m_priv->taskName))
{
if (LogLog::isDebugEnabled())
Expand Down
4 changes: 2 additions & 2 deletions src/main/cpp/threadutility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ struct ThreadUtility::priv_data
std::condition_variable interrupt;
std::mutex interrupt_mutex;
bool terminated{false};
int retryCount{2};
Period maxDelay;
int retryCount{ 2 };
Period maxDelay{ 0 };

void doPeriodicTasks();

Expand Down
1 change: 0 additions & 1 deletion src/main/include/log4cxx/helpers/threadutility.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ LOG4CXX_PTR_DEF(ThreadUtility);
class LOG4CXX_EXPORT ThreadUtility
{
private:
friend class LOG4CXX_NS::helpers::WideLife<ThreadUtility>;
friend class LOG4CXX_NS::helpers::SingletonHolder<ThreadUtility>;
ThreadUtility();

Expand Down

0 comments on commit e8c656a

Please sign in to comment.