Grid calculations: Free memory after data has been read

When data has been read for a variable, free the related data to make sure the memory footprint is as low as possible.
This commit is contained in:
Magne Sjaastad
2024-01-18 14:09:07 +01:00
parent e1007ca957
commit d61838940a
3 changed files with 22 additions and 9 deletions

View File

@@ -742,10 +742,14 @@ void RigCaseCellResultsData::freeAllocatedResultsData( std::vector<RiaDefines::R
}
auto& dataForTimeStep = m_cellScalarResults[resultIdx][index];
// Using swap with an empty vector as that is the safest way to really get rid of the allocated data in a
// vector
std::vector<double> empty;
dataForTimeStep.swap( empty );
if ( !dataForTimeStep.empty() )
{
// Using swap with an empty vector as that is the safest way to really get rid of the allocated data in a
// vector
std::vector<double> empty;
dataForTimeStep.swap( empty );
}
}
}
}