From f9028f1945e3ad87cda1b3001611632b1b424467 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 7 Nov 2016 15:09:31 +0100 Subject: vcl: improve accounting of SVG images in graphics cache The problem is that the graphics cache only counts the size of the SVG text, which is stored in SvgData::maSvgDataArray. However the SvgData::maSequence may use a lot more memory, as it may contain de-compressed bitmaps that are stored as base64-encoded PNGs in the SVG text. For example icon-themes/galaxy/brand/flat_logo.svg is 812 Ko but contains 60 Mo of bitmaps. This may cause excessive memory usage and failure to export documents due to OOM; according to valgrind massif, the bitmap buffers use 90% of the heap. Add a new interface com::sun::star::util::XAccounting, and implement it in drawinglayer BasePrimitive2D. VCL SvgData can't access drawinglayer via C++ directly so this looks like the best approach. Change-Id: I5a7c3147733e23473c1decabed24c1f79d951c7d Reviewed-on: https://gerrit.libreoffice.org/30669 Tested-by: Jenkins Reviewed-by: Michael Stahl --- offapi/UnoApi_offapi.mk | 1 + offapi/com/sun/star/util/XAccounting.idl | 34 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 offapi/com/sun/star/util/XAccounting.idl (limited to 'offapi') diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk index 9d44e995f497..a14aff613958 100644 --- a/offapi/UnoApi_offapi.mk +++ b/offapi/UnoApi_offapi.mk @@ -4113,6 +4113,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/util,\ TriState \ URL \ VetoException \ + XAccounting \ XAtomServer \ XBroadcaster \ XCancellable \ diff --git a/offapi/com/sun/star/util/XAccounting.idl b/offapi/com/sun/star/util/XAccounting.idl new file mode 100644 index 000000000000..545a16ad5a00 --- /dev/null +++ b/offapi/com/sun/star/util/XAccounting.idl @@ -0,0 +1,34 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef __com_sun_star_util_XAccounting_idl__ +#define __com_sun_star_util_XAccounting_idl__ + +#include + +module com { module sun { module star { module util { + +/** allows estimating the memory usage of a service. + + @since LibreOffice 5.3 + */ +interface XAccounting : com::sun::star::uno::XInterface +{ + + /** @returns an estimate of the current memory usage, in octets. + */ + hyper estimateUsage(); + +}; + +}; }; }; }; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ -- cgit