mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Fixed Memory bug regarding statistics calcualtion
The results memory on each timestep was not freed resulting in all the data from all the cases for all timesteps in memory at the same time ... In addition, the data was read accidentaly before the timeloop for all the source cases for all timesteps. So, should perform better now, but there still are some memory allocated in the start, that i cant quite account for. p4#: 22011
This commit is contained in:
parent
cff0437343
commit
4f7b3e703c
@ -85,7 +85,7 @@ void RimStatisticsCaseEvaluator::buildSourceMetaData(RifReaderInterface::Porosit
|
||||
for (size_t caseIdx = 1; caseIdx < m_sourceCases.size(); caseIdx++)
|
||||
{
|
||||
RimReservoirCellResultsStorage* cellResultsStorage = m_sourceCases[caseIdx]->results(poroModel);
|
||||
size_t scalarResultIndex = cellResultsStorage->findOrLoadScalarResult(resultType, resultName);
|
||||
size_t scalarResultIndex = cellResultsStorage->cellResults()->findScalarResultIndex(resultType, resultName);
|
||||
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
size_t scalarResultIndex = cellResultsStorage->cellResults()->addEmptyScalarResult(resultType, resultName, false);
|
||||
@ -202,11 +202,11 @@ void RimStatisticsCaseEvaluator::evaluateForResults(const QList<ResSpec>& result
|
||||
cvf::Collection<cvf::StructGridScalarDataAccess> sourceDataAccessList;
|
||||
for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++)
|
||||
{
|
||||
RimCase* eclipseCase = m_sourceCases.at(caseIdx);
|
||||
RimCase* sourceCase = m_sourceCases.at(caseIdx);
|
||||
|
||||
size_t scalarResultIndex = eclipseCase->results(poroModel)->findOrLoadScalarResultForTimeStep(resultType, resultName, dataAccessTimeStepIndex);
|
||||
size_t scalarResultIndex = sourceCase->results(poroModel)->findOrLoadScalarResultForTimeStep(resultType, resultName, dataAccessTimeStepIndex);
|
||||
|
||||
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObject = eclipseCase->reservoirData()->dataAccessObject(grid, poroModel, dataAccessTimeStepIndex, scalarResultIndex);
|
||||
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObject = sourceCase->reservoirData()->dataAccessObject(grid, poroModel, dataAccessTimeStepIndex, scalarResultIndex);
|
||||
if (dataAccessObject.notNull())
|
||||
{
|
||||
sourceDataAccessList.push_back(dataAccessObject.p());
|
||||
@ -327,13 +327,21 @@ void RimStatisticsCaseEvaluator::evaluateForResults(const QList<ResSpec>& result
|
||||
}
|
||||
}
|
||||
|
||||
// When one time step is completed, close all result files.
|
||||
// When one time step is completed, free memory and clean up
|
||||
// Microsoft note: On Windows, the maximum number of files open at the same time is 512
|
||||
// http://msdn.microsoft.com/en-us/library/kdfaxaay%28vs.71%29.aspx
|
||||
|
||||
for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++)
|
||||
{
|
||||
RimCase* eclipseCase = m_sourceCases.at(caseIdx);
|
||||
|
||||
if (!eclipseCase->reservoirViews.size())
|
||||
{
|
||||
eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->freeAllocatedResultsData();
|
||||
eclipseCase->results(RifReaderInterface::FRACTURE_RESULTS)->cellResults()->freeAllocatedResultsData();
|
||||
}
|
||||
|
||||
// Todo : These calls really do nothing right now the access actually closes automatically in ert i belive ...
|
||||
eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->readerInterface()->close();
|
||||
eclipseCase->results(RifReaderInterface::FRACTURE_RESULTS)->readerInterface()->close();
|
||||
}
|
||||
|
@ -521,6 +521,24 @@ void RigCaseCellResultsData::clearAllResults()
|
||||
m_resultInfos.clear();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Removes all the actual numbers put into this object, and frees up the memory.
|
||||
/// Does not touch the metadata in any way
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigCaseCellResultsData::freeAllocatedResultsData()
|
||||
{
|
||||
for (size_t resultIdx = 0; resultIdx < m_cellScalarResults.size(); ++resultIdx)
|
||||
{
|
||||
for (size_t tsIdx = 0; tsIdx < m_cellScalarResults[resultIdx].size(); ++tsIdx)
|
||||
{
|
||||
// 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;
|
||||
m_cellScalarResults[resultIdx][tsIdx].swap(empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Add a result with given type and name, and allocate one result vector for the static result values
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -68,6 +68,7 @@ public:
|
||||
|
||||
void removeResult(const QString& resultName);
|
||||
void clearAllResults();
|
||||
void freeAllocatedResultsData();
|
||||
|
||||
// Access the results data
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user