How to measure effects of OUString::intern ?

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


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>
Date:   Tue Apr 3 13:08:01 2007 +0000

    INTEGRATION: CWS salstrintern (1.45.28); FILE MERGED
    2007/02/08 14:23:59 mmeeks 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.
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(),
                                                    RTL_TEXTENCODING_UTF8 );

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

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



More information about the LibreOffice mailing list