summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2023-04-12 16:01:46 +0100
committerMichael Meeks <michael.meeks@collabora.com>2023-04-14 10:40:56 +0200
commitd65f88621351aaa7bc753edec611619fceac110b (patch)
tree4c12b92503c962b3af508b4b815bdb5422e5e9b2 /desktop
parent515417105729c69e9eef76a48c39f97affce19a9 (diff)
lok: trim glibc allocator's pending heap when called.
Change-Id: I8d1bda01a0e6ccff0fa868013c67c0fbbf78a836 Signed-off-by: Michael Meeks <michael.meeks@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150299 Tested-by: Jenkins (cherry picked from commit faa5ee1e497d6cf7bd4dbce4bf75b6231eb2387a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150315
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/lib/init.cxx12
1 files changed, 12 insertions, 0 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 4caa1b034d86..20cc63231cbd 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -26,8 +26,14 @@
#include <postmac.h>
#endif
+#undef HAVE_MALLOC_TRIM
+
#ifdef LINUX
#include <fcntl.h>
+#if defined __GLIBC__
+# include <malloc.h>
+# define HAVE_MALLOC_TRIM
+#endif
#endif
#ifdef ANDROID
@@ -3153,6 +3159,12 @@ static char* lo_extractRequest(LibreOfficeKit* /*pThis*/, const char* pFilePath)
static void lo_trimMemory(LibreOfficeKit* /* pThis */, int nTarget)
{
vcl::lok::trimMemory(nTarget);
+ if (nTarget > 1000)
+ {
+#ifdef HAVE_MALLOC_TRIM
+ malloc_trim(0);
+#endif
+ }
}
static void lo_registerCallback (LibreOfficeKit* pThis,