From ca2d13c442147db69085e327a73641a8aa280a50 Mon Sep 17 00:00:00 2001 From: Andrey Skvortsov Date: Mon, 13 Sep 2010 17:54:29 -0700 Subject: [PATCH] severe memory leak in thumbimageupdater._process --- rtgui/thumbimageupdater.cc | 25 +++++++++++++++++-------- rtgui/thumbimageupdater.h | 2 ++ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/rtgui/thumbimageupdater.cc b/rtgui/thumbimageupdater.cc index 78d7ece01..2e90e9eb8 100644 --- a/rtgui/thumbimageupdater.cc +++ b/rtgui/thumbimageupdater.cc @@ -19,11 +19,19 @@ #include #include +#define threadNum 4 // IF LCMS GETS THREAD SAFETY WE CAN ENABLE MORE THREADS ThumbImageUpdater thumbImageUpdater; ThumbImageUpdater::ThumbImageUpdater () : tostop(false), stopped(true), qMutex(NULL), startMutex(NULL) { - + + threadPool = new Glib::Thread* [threadNum]; + +} + +ThumbImageUpdater::~ThumbImageUpdater () +{ + delete threadPool; } void ThumbImageUpdater::add (Thumbnail* t, const rtengine::procparams::ProcParams& params, int height, bool* priority, ThumbImageUpdateListener* l) { @@ -59,9 +67,9 @@ void ThumbImageUpdater::add (Thumbnail* t, const rtengine::procparams::ProcParam void ThumbImageUpdater::process () { if (stopped) { - #undef THREAD_PRIORITY_NORMAL + #undef THREAD_PRIORITY_LOW stopped = false; - thread = Glib::Thread::create(sigc::mem_fun(*this, &ThumbImageUpdater::process_), (unsigned long int)0, true, true, Glib::THREAD_PRIORITY_NORMAL); + thread = Glib::Thread::create(sigc::mem_fun(*this, &ThumbImageUpdater::process_), (unsigned long int)0, true, true, Glib::THREAD_PRIORITY_LOW); } } @@ -70,9 +78,7 @@ void ThumbImageUpdater::process_ () { stopped = false; tostop = false; - #define threadNum 4 // IF LCMS GETS THREAD SAFETY WE CAN ENABLE MORE THREADS - Glib::Thread **threadPool = new Glib::Thread* [threadNum]; - + while (!tostop && !jqueue.empty ()) { qMutex->lock (); @@ -89,14 +95,17 @@ void ThumbImageUpdater::process_ () { jqueue.erase (i); if (current.listener) threadPool[threads] = Glib::Thread::create(sigc::bind(sigc::mem_fun(*this, &ThumbImageUpdater::processJob), current), 0, true, true, Glib::THREAD_PRIORITY_LOW); - else - threadPool[threads] = NULL; + //else + // threadPool[threads] = NULL; } qMutex->unlock (); for (int j=0; jjoin (); + + for(int j =0; j