logic: Use sizeof(SharedMemory::String) in shared memory size estimation instead of std::string (issue #471)

This commit is contained in:
Eberhard Graether
2017-10-13 12:26:45 +02:00
parent 1d9b322e3e
commit a7363b329b
15 changed files with 38 additions and 37 deletions
@@ -19,12 +19,12 @@ InterprocessIndexerCommandManager::~InterprocessIndexerCommandManager()
void InterprocessIndexerCommandManager::setIndexerCommands(
const std::vector<std::shared_ptr<IndexerCommand>>& indexerCommands)
{
const unsigned int overestimationMultiplier = 3;
const size_t overestimationMultiplier = 2;
size_t estimatedSize = 1048576; /* 1 MB */
for (auto& command : indexerCommands)
{
estimatedSize += command->getByteSize() + sizeof(SharedIndexerCommand);
estimatedSize += command->getByteSize(sizeof(SharedMemory::String)) + sizeof(SharedIndexerCommand);
}
estimatedSize *= overestimationMultiplier;
@@ -39,10 +39,10 @@ void InterprocessIndexingStatusManager::startIndexingSourceFile(const FilePath&
SharedMemory::Map<Id, SharedMemory::String>::iterator it = currentFilesPtr->find(getProcessId());
if (it != currentFilesPtr->end())
{
const int overestimationMultiplier = 3;
const size_t overestimationMultiplier = 3;
const std::string crashedFilePath = it->second.c_str();
size_t estimatedSize = 262144 + sizeof(std::string) + crashedFilePath.size();
size_t estimatedSize = 262144 + sizeof(SharedMemory::String) + crashedFilePath.size();
estimatedSize *= overestimationMultiplier;
while (access.getFreeMemorySize() < estimatedSize)
@@ -215,7 +215,7 @@ void InterprocessIndexingStatusManager::addIndexedFiles(std::set<FilePath> fileP
size_t estimatedSize = 262144;
for (auto& newFile : newFiles)
{
estimatedSize += sizeof(std::string) + newFile.size();
estimatedSize += sizeof(SharedMemory::String) + newFile.size();
}
estimatedSize *= overestimationMultiplier;
@@ -27,8 +27,9 @@ InterprocessIntermediateStorageManager::~InterprocessIntermediateStorageManager(
void InterprocessIntermediateStorageManager::pushIntermediateStorage(
const std::shared_ptr<IntermediateStorage>& intermediateStorage)
{
const unsigned int overestimationMultiplier = 3;
size_t size = (intermediateStorage->getByteSize() + sizeof(SharedIntermediateStorage)) * overestimationMultiplier + 1048576/* 1 MB */;
const size_t overestimationMultiplier = 2;
size_t size = (intermediateStorage->getByteSize(sizeof(SharedMemory::String)) +
sizeof(SharedIntermediateStorage)) * overestimationMultiplier + 1048576/* 1 MB */;
SharedMemory::ScopedAccess access(&m_sharedMemory);