logic: implemented shrinking shared memory to fit required amount from time to time

This commit is contained in:
mlangkabel
2018-11-05 10:38:48 +01:00
parent f13aec70dd
commit d2cd236318
6 changed files with 40 additions and 17 deletions
@@ -46,6 +46,15 @@ void SharedMemory::ScopedAccess::growMemory(size_t size)
m_memory = boost::interprocess::managed_shared_memory(boost::interprocess::open_only, m_memoryName.c_str());
}
void SharedMemory::ScopedAccess::shrinkToFitMemory()
{
m_memory = boost::interprocess::managed_shared_memory();
boost::interprocess::managed_shared_memory::shrink_to_fit(m_memoryName.c_str());
m_memory = boost::interprocess::managed_shared_memory(boost::interprocess::open_only, m_memoryName.c_str());
}
std::string SharedMemory::ScopedAccess::logString() const
{
std::string log = m_memoryName + " -";
@@ -62,6 +62,7 @@ public:
size_t getUsedMemorySize() const;
void growMemory(size_t size);
void shrinkToFitMemory();
template <typename T>
T* accessValue(const std::string& key)