[Libreoffice-commits] core.git: sc/source
Caolán McNamara
caolanm at redhat.com
Mon Oct 23 12:26:35 UTC 2017
sc/source/core/tool/scmatrix.cxx | 29 +++++++++++++++++++++++++----
1 file changed, 25 insertions(+), 4 deletions(-)
New commits:
commit c7c144fc7ae032536d9954ff91ef2823f944b7f7
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Oct 19 21:22:30 2017 +0100
ofz: cluster of oom with multiple large ScMatrix
Change-Id: I39b628ad2014f69d88c1a32d0dbd2a4c4d8c695e
Reviewed-on: https://gerrit.libreoffice.org/43576
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Eike Rathke <erack at redhat.com>
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index c012bc8dcd89..7df5dbe52793 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -336,17 +336,30 @@ private:
void CalcPosition(SCSIZE nIndex, SCSIZE& rC, SCSIZE& rR) const;
};
+static bool bElementsMaxFetched;
+static size_t nElementsMax;
+
ScMatrixImpl::ScMatrixImpl(SCSIZE nC, SCSIZE nR) :
- maMat(nR, nC), maMatFlag(nR, nC), pErrorInterpreter(nullptr) {}
+ maMat(nR, nC), maMatFlag(nR, nC), pErrorInterpreter(nullptr)
+{
+ nElementsMax -= GetElementCount();
+}
ScMatrixImpl::ScMatrixImpl(SCSIZE nC, SCSIZE nR, double fInitVal) :
- maMat(nR, nC, fInitVal), maMatFlag(nR, nC), pErrorInterpreter(nullptr) {}
+ maMat(nR, nC, fInitVal), maMatFlag(nR, nC), pErrorInterpreter(nullptr)
+{
+ nElementsMax -= GetElementCount();
+}
ScMatrixImpl::ScMatrixImpl( size_t nC, size_t nR, const std::vector<double>& rInitVals ) :
- maMat(nR, nC, rInitVals.begin(), rInitVals.end()), maMatFlag(nR, nC), pErrorInterpreter(nullptr) {}
+ maMat(nR, nC, rInitVals.begin(), rInitVals.end()), maMatFlag(nR, nC), pErrorInterpreter(nullptr)
+{
+ nElementsMax -= GetElementCount();
+}
ScMatrixImpl::~ScMatrixImpl() COVERITY_NOEXCEPT_FALSE
{
+ nElementsMax += GetElementCount();
Clear();
}
@@ -358,6 +371,7 @@ void ScMatrixImpl::Clear()
void ScMatrixImpl::Resize(SCSIZE nC, SCSIZE nR)
{
+ nElementsMax += GetElementCount();
if (ScMatrix::IsSizeAllocatable( nC, nR))
{
maMat.resize(nR, nC);
@@ -369,10 +383,12 @@ void ScMatrixImpl::Resize(SCSIZE nC, SCSIZE nR)
maMat.resize(1, 1, CreateDoubleError( FormulaError::MatrixSize));
maMatFlag.resize(1, 1);
}
+ nElementsMax -= GetElementCount();
}
void ScMatrixImpl::Resize(SCSIZE nC, SCSIZE nR, double fVal)
{
+ nElementsMax += GetElementCount();
if (ScMatrix::IsSizeAllocatable( nC, nR))
{
maMat.resize(nR, nC, fVal);
@@ -384,6 +400,7 @@ void ScMatrixImpl::Resize(SCSIZE nC, SCSIZE nR, double fVal)
maMat.resize(1, 1, CreateDoubleError( FormulaError::StackOverflow));
maMatFlag.resize(1, 1);
}
+ nElementsMax -= GetElementCount();
}
void ScMatrixImpl::SetErrorInterpreter( ScInterpreter* p)
@@ -2761,8 +2778,12 @@ bool ScMatrix::IsSizeAllocatable( SCSIZE nC, SCSIZE nR )
if (!nC || !nR)
return true;
- static size_t nElementsMax = std::getenv("SC_MAX_MATRIX_ELEMENTS") ? std::atoi(std::getenv("SC_MAX_MATRIX_ELEMENTS"))
+ if (!bElementsMaxFetched)
+ {
+ nElementsMax = std::getenv("SC_MAX_MATRIX_ELEMENTS") ? std::atoi(std::getenv("SC_MAX_MATRIX_ELEMENTS"))
: ScMatrix::GetElementsMax();
+ bElementsMaxFetched = true;
+ }
if (nC > (nElementsMax / nR))
{
More information about the Libreoffice-commits
mailing list