Commit 13830f64 authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Fixing a bunch of memory leaks.

According to Visual Leak Detector, CAMPVis is now memory leak free. :)
parent ee66aac2
...@@ -35,13 +35,16 @@ ...@@ -35,13 +35,16 @@
#include "tgt/qt/qtthreadedcanvas.h" #include "tgt/qt/qtthreadedcanvas.h"
#include "application/campvispainter.h" #include "application/campvispainter.h"
#include "application/gui/properties/propertywidgetfactory.h"
#include "application/gui/mainwindow.h" #include "application/gui/mainwindow.h"
#include "core/tools/job.h" #include "core/tools/job.h"
#include "core/tools/opengljobprocessor.h" #include "core/tools/opengljobprocessor.h"
#include "core/tools/simplejobprocessor.h" #include "core/tools/simplejobprocessor.h"
#include "core/tools/stringutils.h" #include "core/tools/stringutils.h"
#include "core/tools/quadrenderer.h" #include "core/tools/quadrenderer.h"
#include "core/pipeline/abstractpipeline.h" #include "core/pipeline/abstractpipeline.h"
#include "core/datastructures/imagerepresentationconverter.h"
#include "core/pipeline/visualizationprocessor.h" #include "core/pipeline/visualizationprocessor.h"
#include "modules/pipelinefactory.h" #include "modules/pipelinefactory.h"
...@@ -210,13 +213,16 @@ namespace campvis { ...@@ -210,13 +213,16 @@ namespace campvis {
tgt::deinitGL(); tgt::deinitGL();
} }
SimpleJobProcessor::deinit();
OpenGLJobProcessor::deinit();
PipelineFactory::deinit();
tgt::GlContextManager::deinit(); tgt::GlContextManager::deinit();
tgt::deinit(); tgt::deinit();
OpenGLJobProcessor::deinit();
SimpleJobProcessor::deinit();
PropertyWidgetFactory::deinit();
ImageRepresentationConverter::deinit();
PipelineFactory::deinit();
// MainWindow dtor needs a valid CampVisApplication, so we need to call it here instead of during destruction. // MainWindow dtor needs a valid CampVisApplication, so we need to call it here instead of during destruction.
delete _mainWindow; delete _mainWindow;
......
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
#include <ctime> #include <ctime>
#ifdef CAMPVIS_DEBUG
// Anonymous OpenGL helper functions // Anonymous OpenGL helper functions
namespace { namespace {
GLboolean getGlBool(GLenum param) { GLboolean getGlBool(GLenum param) {
...@@ -57,6 +59,7 @@ namespace { ...@@ -57,6 +59,7 @@ namespace {
return toReturn; return toReturn;
} }
} }
#endif
namespace campvis { namespace campvis {
......
...@@ -37,7 +37,7 @@ namespace campvis { ...@@ -37,7 +37,7 @@ namespace campvis {
size = 1; size = 1;
while (true) { while (true) {
void* toReturn = OpenGLJobProcessor::getRef()._signalPool.malloc(size); void* toReturn = OpenGLJobProcessor::getRef()._jobPool.malloc(size);
if (toReturn != nullptr) if (toReturn != nullptr)
return toReturn; return toReturn;
...@@ -57,7 +57,7 @@ namespace campvis { ...@@ -57,7 +57,7 @@ namespace campvis {
if (rawMemory == nullptr) if (rawMemory == nullptr)
return; return;
OpenGLJobProcessor::getRef()._signalPool.free(rawMemory); OpenGLJobProcessor::getRef()._jobPool.free(rawMemory);
} }
} }
...@@ -71,6 +71,7 @@ namespace campvis { ...@@ -71,6 +71,7 @@ namespace campvis {
_contextQueueMap.clear(); _contextQueueMap.clear();
_contexts.clear(); _contexts.clear();
_jobPool.recycle();
} }
void OpenGLJobProcessor::stop() { void OpenGLJobProcessor::stop() {
......
...@@ -212,7 +212,7 @@ namespace campvis { ...@@ -212,7 +212,7 @@ namespace campvis {
private: private:
typedef std::allocator<AbstractJob> pool_allocator_t; typedef std::allocator<AbstractJob> pool_allocator_t;
tbb::memory_pool<pool_allocator_t> _signalPool; ///< Memory pool for the signals tbb::memory_pool<pool_allocator_t> _jobPool; ///< Memory pool for the signals
static std::thread::id _this_thread_id; static std::thread::id _this_thread_id;
}; };
......
...@@ -46,6 +46,7 @@ namespace campvis { ...@@ -46,6 +46,7 @@ namespace campvis {
void PipelineFactory::deinit() { void PipelineFactory::deinit() {
delete _singleton; delete _singleton;
_singleton = nullptr;
} }
......
...@@ -92,7 +92,7 @@ namespace campvis { ...@@ -92,7 +92,7 @@ namespace campvis {
} }
VolumeRenderer::~VolumeRenderer() { VolumeRenderer::~VolumeRenderer() {
delete _raycaster;
} }
void VolumeRenderer::init() { void VolumeRenderer::init() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment