#11258 Grid Calculation: Unintended release of result data memory

Avoid release of memory when working on a single case
This commit is contained in:
Magne Sjaastad 2024-03-05 12:10:02 +01:00
parent 406cd087e9
commit 9f96cb9694
2 changed files with 11 additions and 3 deletions

View File

@ -609,10 +609,13 @@ std::vector<double> RimGridCalculation::getDataForResult( const QString&
values[i] = resultAccessor->cellScalarGlobIdx( activeReservoirCells[i] );
}
auto categoriesToExclude = { RiaDefines::ResultCatType::GENERATED };
if ( m_releaseMemoryAfterDataIsExtracted )
{
auto categoriesToExclude = { RiaDefines::ResultCatType::GENERATED };
sourceCase->results( RiaDefines::PorosityModelType::MATRIX_MODEL )->freeAllocatedResultsData( categoriesToExclude, timeStepToUse );
sourceCase->results( RiaDefines::PorosityModelType::FRACTURE_MODEL )->freeAllocatedResultsData( categoriesToExclude, timeStepToUse );
sourceCase->results( RiaDefines::PorosityModelType::MATRIX_MODEL )->freeAllocatedResultsData( categoriesToExclude, timeStepToUse );
sourceCase->results( RiaDefines::PorosityModelType::FRACTURE_MODEL )->freeAllocatedResultsData( categoriesToExclude, timeStepToUse );
}
return values;
}
@ -782,6 +785,9 @@ bool RimGridCalculation::calculateForCases( const std::vector<RimEclipseCase*>&
m_expression().contains( "min" ) || m_expression().contains( "max" ) ||
m_expression().contains( "count" );
// If multiple cases are present, release memory after data is extracted to avoid memory issues.
m_releaseMemoryAfterDataIsExtracted = isMultipleCasesPresent;
if ( isMultipleCasesPresent )
{
QString txt = "Starting calculation '" + description() + "' for " + QString::number( calculationCases.size() ) + " cases.";

View File

@ -155,4 +155,6 @@ private:
caf::PdmField<bool> m_editNonVisibleResultAddress;
caf::PdmField<bool> m_applyToAllCases_OBSOLETE;
bool m_releaseMemoryAfterDataIsExtracted = false;
};