From f0443fa4438aa98bce48bfd53dc6a687737687b6 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Mon, 14 Oct 2019 15:05:19 +0200 Subject: Add option to prevent graphic swap out Change-Id: Icbfc21b219cd4ba582e798e5deda6ef7c81a2009 Reviewed-on: https://gerrit.libreoffice.org/80773 Tested-by: Jenkins Reviewed-by: Thorsten Behrens --- .../registry/schema/org/openoffice/Office/Common.xcs | 8 ++++++++ vcl/inc/graphic/Manager.hxx | 1 + vcl/source/graphic/Manager.cxx | 20 ++++++++++++++------ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index 0fd0786a77a9..0c6b90fea58d 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -1524,6 +1524,14 @@ 600 + + + Whether graphics will be swapped to disk when `GraphicMemoryLimit` + is reached. Disable at your own risk. + + + true + Specifies the allowed cumulated memory that the diff --git a/vcl/inc/graphic/Manager.hxx b/vcl/inc/graphic/Manager.hxx index a756450caf28..f1413877bb08 100644 --- a/vcl/inc/graphic/Manager.hxx +++ b/vcl/inc/graphic/Manager.hxx @@ -35,6 +35,7 @@ private: std::recursive_mutex maMutex; // instead of SolarMutex because graphics can live past vcl main std::unordered_set m_pImpGraphicList; std::chrono::seconds mnAllowedIdleTime; + bool mbSwapEnabled; sal_Int64 mnMemoryLimit; sal_Int64 mnUsedSize; Timer maSwapOutTimer; diff --git a/vcl/source/graphic/Manager.cxx b/vcl/source/graphic/Manager.cxx index ec2bdca9be0b..5942b5cb8784 100644 --- a/vcl/source/graphic/Manager.cxx +++ b/vcl/source/graphic/Manager.cxx @@ -33,7 +33,7 @@ namespace graphic namespace { void setupConfigurationValuesIfPossible(sal_Int64& rMemoryLimit, - std::chrono::seconds& rAllowedIdleTime) + std::chrono::seconds& rAllowedIdleTime, bool& bSwapEnabled) { if (utl::ConfigManager::IsFuzzing()) return; @@ -45,6 +45,7 @@ void setupConfigurationValuesIfPossible(sal_Int64& rMemoryLimit, rMemoryLimit = Cache::GraphicManager::GraphicMemoryLimit::get(); rAllowedIdleTime = std::chrono::seconds(Cache::GraphicManager::GraphicAllowedIdleTime::get()); + bSwapEnabled = Cache::GraphicManager::GraphicSwappingEnabled::get(); } catch (...) { @@ -60,20 +61,27 @@ Manager& Manager::get() Manager::Manager() : mnAllowedIdleTime(10) + , mbSwapEnabled(true) , mnMemoryLimit(300000000) , mnUsedSize(0) , maSwapOutTimer("graphic::Manager maSwapOutTimer") { - setupConfigurationValuesIfPossible(mnMemoryLimit, mnAllowedIdleTime); + setupConfigurationValuesIfPossible(mnMemoryLimit, mnAllowedIdleTime, mbSwapEnabled); - maSwapOutTimer.SetInvokeHandler(LINK(this, Manager, SwapOutTimerHandler)); - maSwapOutTimer.SetTimeout(10000); - maSwapOutTimer.SetDebugName("graphic::Manager maSwapOutTimer"); - maSwapOutTimer.Start(); + if (mbSwapEnabled) + { + maSwapOutTimer.SetInvokeHandler(LINK(this, Manager, SwapOutTimerHandler)); + maSwapOutTimer.SetTimeout(10000); + maSwapOutTimer.SetDebugName("graphic::Manager maSwapOutTimer"); + maSwapOutTimer.Start(); + } } void Manager::reduceGraphicMemory() { + if (!mbSwapEnabled) + return; + std::scoped_lock aGuard(maMutex); for (ImpGraphic* pEachImpGraphic : m_pImpGraphicList) -- cgit