Mercurial > hg > svcore
diff data/fft/FFTDataServer.cpp @ 205:05154c7bb90b
* Basics of an approximate way of managing memory that we've committed to using
but haven't allocated yet
author | Chris Cannam |
---|---|
date | Fri, 15 Dec 2006 18:05:31 +0000 |
parents | 11e107062a2b |
children | e0e7f6c5fda9 |
line wrap: on
line diff
--- a/data/fft/FFTDataServer.cpp Tue Dec 12 10:41:41 2006 +0000 +++ b/data/fft/FFTDataServer.cpp Fri Dec 15 18:05:31 2006 +0000 @@ -393,6 +393,11 @@ std::cerr << "Width " << m_width << ", cache width " << m_cacheWidth << " (size " << m_cacheWidth * columnSize << ")" << std::endl; #endif + StorageAdviser::notifyPlannedAllocation + (m_memoryCache ? StorageAdviser::MemoryAllocation : + StorageAdviser::DiscAllocation, + m_compactCache ? minimumSize : maximumSize); + for (size_t i = 0; i <= m_width / m_cacheWidth; ++i) { m_caches.push_back(0); } @@ -436,7 +441,15 @@ QMutexLocker locker(&m_writeMutex); for (CacheVector::iterator i = m_caches.begin(); i != m_caches.end(); ++i) { - delete *i; + if (*i) { + delete *i; + } else { + StorageAdviser::notifyDoneAllocation + (m_memoryCache ? StorageAdviser::MemoryAllocation : + StorageAdviser::DiscAllocation, + m_cacheWidth * m_height * + (m_compactCache ? sizeof(uint16_t) : sizeof(float)) / 1024 + 1); + } } deleteProcessingData(); @@ -583,6 +596,12 @@ cache->resize(width, m_height); cache->reset(); + StorageAdviser::notifyDoneAllocation + (m_memoryCache ? StorageAdviser::MemoryAllocation : + StorageAdviser::DiscAllocation, + width * m_height * + (m_compactCache ? sizeof(uint16_t) : sizeof(float)) / 1024 + 1); + } catch (std::bad_alloc) { std::cerr << "ERROR: Memory allocation failed in FFTFileCache::resize:" << " abandoning this cache" << std::endl;