desktop/source/lib/init.cxx             |    1 +
 include/LibreOfficeKit/LibreOfficeKit.h |    2 +-
 vcl/source/app/svapp.cxx                |    4 ++--
 vcl/source/gdi/impgraph.cxx             |   11 +++++++++--
 vcl/source/graphic/Manager.cxx          |    3 +--
 5 files changed, 14 insertions(+), 7 deletions(-)

New commits:
commit 8fd1dacbc4fdb586ea9c7bc0f405641eb3058e04
Author:     Michael Meeks <michael.me...@collabora.com>
AuthorDate: Sat Mar 11 15:56:04 2023 +0000
Commit:     Michael Meeks <michael.me...@collabora.com>
CommitDate: Sat Mar 11 21:06:00 2023 +0000

    lok: cleanup trimMemory capability, and expand dumpState to caches.
    
    Being able to trigger some more aggressive memory saving is
    useful in for both online and mobile.
    
    Signed-off-by: Michael Meeks <michael.me...@collabora.com>
    Change-Id: If740469a59e7e1896e5952dbcd28742446c7559d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148684

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 28849bb4161e..07bb6be18fa0 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2567,6 +2567,7 @@ LibLibreOffice_Impl::LibLibreOffice_Impl()
         m_pOfficeClass->setOption = lo_setOption;
         m_pOfficeClass->dumpState = lo_dumpState;
         m_pOfficeClass->extractRequest = lo_extractRequest;
+        m_pOfficeClass->trimMemory = lo_trimMemory;
 
         gOfficeClass = m_pOfficeClass;
     }
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h 
b/include/LibreOfficeKit/LibreOfficeKit.h
index 219013f6fb9f..e98ea6f47f42 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -119,7 +119,7 @@ struct _LibreOfficeKitClass
     /// @see lok::Office::setOption
     void (*setOption) (LibreOfficeKit* pThis, const char* pOption, const char* 
pValue);
 
-    /// @see lok::Document::dumpState
+    /// @see lok::Office::dumpState
     /// @since LibreOffice 7.5
     void (*dumpState) (LibreOfficeKit* pThis, const char* pOptions, char** 
pState);
 
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index adc98af951ef..5359ac139532 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -1887,8 +1887,8 @@ void trimMemory(int nTarget)
             return;
         pSVData->dropCaches();
         vcl::graphic::Manager::get().dropCache();
-        // free up any deeper dirtied thread stacks.
-        comphelper::ThreadPool::getSharedOptimalPool().shutdown();
+        // TODO: ideally - free up any deeper dirtied thread stacks.
+        // comphelper::ThreadPool::getSharedOptimalPool().shutdown();
     }
     // else for now caches re-fill themselves as/when used.
 }
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 6011e17feb75..3b8029b362de 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -1424,6 +1424,9 @@ void ImpGraphic::updateFromLoadedGraphic(const 
ImpGraphic* pGraphic)
 
 void ImpGraphic::dumpState(rtl::OStringBuffer &rState)
 {
+    if (meType == GraphicType::NONE && mnSizeBytes == 0)
+        return; // uninteresting.
+
     rState.append("\n\t");
 
     if (mbSwapOut)
@@ -1433,8 +1436,12 @@ void ImpGraphic::dumpState(rtl::OStringBuffer &rState)
 
     rState.append(static_cast<sal_Int32>(meType));
     rState.append("\tsize:\t");
-    rState.append(static_cast<sal_Int64>(mnSizeBytes/1024));
-    rState.append("\tkb\t");
+    rState.append(static_cast<sal_Int64>(mnSizeBytes));
+    rState.append("\t");
+    rState.append(static_cast<sal_Int32>(maSwapInfo.maSizePixel.Width()));
+    rState.append("x");
+    rState.append(static_cast<sal_Int32>(maSwapInfo.maSizePixel.Height()));
+    rState.append("\t");
     rState.append(static_cast<sal_Int32>(maExPrefSize.Width()));
     rState.append("x");
     rState.append(static_cast<sal_Int32>(maExPrefSize.Height()));
diff --git a/vcl/source/graphic/Manager.cxx b/vcl/source/graphic/Manager.cxx
index 80aac3948cc6..d43a617a7272 100644
--- a/vcl/source/graphic/Manager.cxx
+++ b/vcl/source/graphic/Manager.cxx
@@ -92,7 +92,7 @@ void 
Manager::loopGraphicsAndSwapOut(std::unique_lock<std::mutex>& rGuard, bool
             continue;
 
         sal_Int64 nCurrentGraphicSize = getGraphicSizeBytes(pEachImpGraphic);
-        if (nCurrentGraphicSize > 100000)
+        if (nCurrentGraphicSize > 100000 || bDropAll)
         {
             if (!pEachImpGraphic->mpContext)
             {
@@ -166,7 +166,6 @@ void Manager::dumpState(rtl::OStringBuffer &rState)
     rState.append(static_cast<sal_Int64>(mnUsedSize/1024));
     rState.append("\tkb");
 
-    sal_Int32 i = 0;
     for (ImpGraphic* pEachImpGraphic : m_pImpGraphicList)
     {
         pEachImpGraphic->dumpState(rState);

Reply via email to