How to measure effects of OUString::intern ?

Mark Wielaard mark at klomp.org
Mon Jul 29 09:35:47 PDT 2013


Hi,

I was looking at memory usage and noticed OUString::intern being used
in ZipFile::readCEN. This was introduced a long time ago, so I was
wondering if it is still beneficial:

commit f86cafc3c7baab6f08263e4550dffa26f51811bc
Author: Rüdiger Timm <rt at openoffice.org>
Date:   Tue Apr 3 13:08:01 2007 +0000

    INTEGRATION: CWS salstrintern (1.45.28); FILE MERGED
    2007/02/08 14:23:59 mmeeks 1.45.28.1: Issue number: i#74343
    Submitted by: mmeeks
    'intern' all ZipFile stream name strings - they're duplicated elsewhere.

I couldn't immediately find the duplication of the names.
In this case the strings are the full zip file entry paths. e.g.
"sw/res/sidebar/pageproppanel/portraitcopy_24x24.png"
And as far as I can see all the full path names are unique, so no
actual sharing is taking place here. But is there a place where these
strings are reused (and also interned)?

Replacing the intern with a normal OUString constructor like:

--- a/package/source/zipapi/ZipFile.cxx
+++ b/package/source/zipapi/ZipFile.cxx
@@ -847,7 +847,7 @@ sal_Int32 ZipFile::readCEN()
                 throw ZipException("unexpected extra header info length", uno::Reference < XInterface > () );
 
             // read always in UTF8, some tools seem not to set UTF8 bit
-            aEntry.sPath = OUString::intern ( (sal_Char *) aMemGrabber.getCurrentPos(),
+            aEntry.sPath = OUString ( (sal_Char *) aMemGrabber.getCurrentPos(),
                                                    aEntry.nPathLen,
                                                    RTL_TEXTENCODING_UTF8 );

Seems to save ~200K of memory at least for a quick:

export OOO_EXIT_POST_STARTUP=1
export OOO_DISABLE_RECOVERY=1
install/program/soffice --valgrind --writer

But that might be too quick to see any effects of this intern action.
I cannot immediately find with which other string intern action this
is/should be paired to see memory savings.

So I guess my general question is how to measure the effects of
OUString::intern?

Thanks,

Mark


More information about the LibreOffice mailing list