summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
authorDennis Francis <dennis.francis@collabora.com>2019-12-04 15:29:06 +0530
committerDennis Francis <dennis.francis@collabora.com>2020-01-04 07:58:06 +0100
commit0b8ae8725083eb0526a262d434cc06fb3f3e7336 (patch)
treefe628f0a7537533ca9b99b255a0bbf07e229af5b /package
parentdd198398b6e5c84ab1255a90ef96e6445b66a64f (diff)
tdf#125662: disable parallel-zip if the memory...
required to carry it out will cause a breach of addressable memory limit. This can happen in 32bit OSes, where the physical memory limit is more than the process addressable memory limit. For example in Win32, a process can address only upto 2GB. More specifically, avoid using ZipOutputEntryParallel which rougly needs twice the memory compared to its counterparts. Change-Id: I4d1abbf75e928188bcf806fcf1e5872b1e51b502 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/84394 Tested-by: Jenkins Reviewed-by: Dennis Francis <dennis.francis@collabora.com>
Diffstat (limited to 'package')
-rw-r--r--package/source/zippackage/ZipPackageStream.cxx5
1 files changed, 4 insertions, 1 deletions
diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx
index 745157cfd02e..d8f9c594d89f 100644
--- a/package/source/zippackage/ZipPackageStream.cxx
+++ b/package/source/zippackage/ZipPackageStream.cxx
@@ -48,6 +48,7 @@
#include <comphelper/seekableinput.hxx>
#include <comphelper/servicehelper.hxx>
#include <comphelper/storagehelper.hxx>
+#include <comphelper/meminfo.hxx>
#include <cppuhelper/exc_hlp.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <cppuhelper/typeprovider.hxx>
@@ -768,7 +769,9 @@ bool ZipPackageStream::saveChild(
// the full size, but it appears that at this point it usually is.
sal_Int64 estimatedSize = xSeek.is() ? xSeek->getLength() : xStream->available();
- if (estimatedSize > 1000000)
+ // ZipOutputEntryParallel/ThreadedDeflater needs to allocate ~twice the estimatedSize.
+ // Check if we can allocate that much without breaching addressable memory limits.
+ if (estimatedSize > 1000000 && comphelper::canAlloc(2*estimatedSize))
{
// Use ThreadDeflater which will split the stream into blocks and compress
// them in threads, but not in background (i.e. writeStream() will block).