From e28fcec04201fb3be19960a0b91fcb20f8d6c56d Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Mon, 13 Aug 2012 10:56:36 +0000 Subject: Fix for [#32220] regression - DistortionCache is never freed. * at max 10 cache items will be available. Items will be removed by latest usage. * number of cached items can be adjusted in code * added deinitialization of compositor when blender exists. * updated scons and cmake build files --- .../operations/COM_MovieDistortionOperation.cpp | 28 +++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'source/blender/compositor/operations/COM_MovieDistortionOperation.cpp') diff --git a/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp b/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp index 8150e3eda75..a3e00e9325b 100644 --- a/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp +++ b/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp @@ -31,6 +31,15 @@ extern "C" { vector s_cache; +void deintializeDistortionCache(void) +{ + while (s_cache.size()>0) + { + DistortionCache * cache = s_cache.back(); + s_cache.pop_back(); + delete cache; + } +} MovieDistortionOperation::MovieDistortionOperation(bool distortion) : NodeOperation() { @@ -52,12 +61,14 @@ void MovieDistortionOperation::initExecution() BKE_movieclip_user_set_frame(&clipUser, this->m_framenumber); BKE_movieclip_get_size(this->m_movieClip, &clipUser, &calibration_width, &calibration_height); - for (unsigned int i = 0; i < s_cache.size(); i++) { + for (unsigned int i = 0; i < s_cache.size(); i++) + { DistortionCache *c = (DistortionCache *)s_cache[i]; if (c->isCacheFor(this->m_movieClip, this->m_width, this->m_height, calibration_width, calibration_height, this->m_distortion)) { this->m_cache = c; + this->m_cache->updateLastUsage(); return; } } @@ -75,6 +86,21 @@ void MovieDistortionOperation::deinitExecution() { this->m_inputOperation = NULL; this->m_movieClip = NULL; + while (s_cache.size() > COM_DISTORTIONCACHE_MAXSIZE) + { + double minTime = PIL_check_seconds_timer(); + vector::iterator minTimeIterator = s_cache.begin(); + for (vector::iterator it = s_cache.begin(); it < s_cache.end(); it ++) + { + DistortionCache * cache = *it; + if (cache->getTimeLastUsage()getTimeLastUsage(); + minTimeIterator = it; + } + } + s_cache.erase(minTimeIterator); + } } -- cgit v1.2.3