Bug 119591 - macOS: Memory isn't released to the initial state when closing a file after saving
Summary: macOS: Memory isn't released to the initial state when closing a file after s...
Status: RESOLVED WORKSFORME
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
6.2.0.0.alpha0+
Hardware: All macOS (All)
: high major
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: perf
Depends on:
Blocks: Memory
  Show dependency treegraph
 
Reported: 2018-08-29 16:00 UTC by Telesto
Modified: 2025-05-12 04:07 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Telesto 2018-08-29 16:00:46 UTC
Description:
MacOS: Memory isn't released to the initial state when closing a file after saving 

Steps to Reproduce:
1. Open attachment 144526 [details]
2. Press Save (very slow; lots of comments)
3. Close the document (back to start center)

Actual Results:
Some around 150-250 MB isn't released

Expected Results:
A bigger drop in memory usage when closing the file (back to start center).

And way-off topic a better saving speed: every comment box seems to be rendered through Harfbuzz while saving (does it really have to?)


Reproducible: Always


User Profile Reset: No



Additional Info:
Version: 6.2.0.0.alpha0+
Build ID: 85818da3307a28b2d9c6fa5c1c97ca7833dfe24c
CPU threads: 4; OS: Mac OS X 10.12.6; UI render: default; 
TinderBox: MacOSX-x86_64@49-TDF, Branch:master, Time: 2018-08-22_04:15:46
Locale: nl-NL (nl_NL.UTF-8); Calc: threaded
Comment 1 Alex Thurgood 2018-09-17 08:12:21 UTC
Hmm, my experimentation so far just shows LO consuming more and more memory to the point where my system becomes unresponsive requiring a force kill of the LO process.

I loaded LOdev master into Instruments.app and then followed memory allocations (until both LO and Insruments became unresponsive).

Once the document is loaded, transient memory allocation is running at 10 Gb.
I made a single digit change to one value without a comment in one cell, and then attempted a re-save.

Instruments shows that memory allocation goes through the roof, passing from 10Gb transient to 85Gb transient memory, at which point my whole system becomes unresponsive. Both LO and Instruments grind to a halt.

The memory guzzlers in this seem to be a combination of:

- rtl_UString_new_WithLength : only 1.5kb each, but a gazillion of them 

- rtl_Ustring_ImplAlloc(int) : quite a few of these too at 416 bytes a throw

This block is pointed to in strtmpl.cxx (1139-1157) 

IMPL_RTL_STRINGDATA* IMPL_RTL_STRINGNAME( ImplAlloc )( sal_Int32 nLen )
{
    IMPL_RTL_STRINGDATA * pData
        = (sal::static_int_cast< sal_uInt32 >(nLen)
           <= ((SAL_MAX_UINT32 - sizeof (IMPL_RTL_STRINGDATA))
               / sizeof (IMPL_RTL_STRCODE)))
        ? static_cast<IMPL_RTL_STRINGDATA *>(rtl_allocateString(
            sizeof (IMPL_RTL_STRINGDATA) + nLen * sizeof (IMPL_RTL_STRCODE)))
        : nullptr;




- I also see loads of calls to SfxItemSet::SfxItemSet(SfxItemSet const&), allegedly from itemset.cxx, but a search in itemset.cxx doesn't return any such line...
Comment 2 Xisco Faulí 2018-09-18 17:08:29 UTC
@Tor, I thought you could be interested in this issue...
Comment 3 How can I remove my account? 2019-01-23 22:10:47 UTC
About Telesto's initial description: What you describe isn't necessarily a bug. If the initial state is the Start Centre, it is very normal that after loading a document (for instance, a Writer one) and then closing that document, a lot of persistent data structures and code related to Writer functionality were constructed in and/or loaded into memory. Those don't go away even if you close the only Writer document open.

What would be a problem is if for each time you open the same document (preferably a simple one that doesn't do any weird things like run BASIC macros etc) and close it, the memory consumption increases a lot.

What Alex describes then sounds like a much more serious and different type of problem indeed.
Comment 4 QA Administrators 2021-01-23 04:03:43 UTC Comment hidden (obsolete)
Comment 5 steve 2025-05-12 03:57:18 UTC
Version: 25.2.3.2 (AARCH64) / LibreOffice Community
Build ID: bbb074479178df812d175f709636b368952c2ce3
CPU threads: 12; OS: macOS 15.4.1; UI render: Skia/Metal; VCL: osx
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded

Open test file: Memory goes from ~500 to ~760 MB
Press save: Memory goes to 1,1 GB
Close document: Memory goes down to ~700 MB

So the initial issue seems to be persisting.

Re-opening the file: back to 1,1 GB
Closing: back to ~700 MB

Version: 25.8.0.0.alpha0+ (AARCH64) / LibreOffice Community
Build ID: cb149972d5fc82f3ca8009c3e51931c8d94ee664
CPU threads: 12; OS: macOS 15.4.1; UI render: Skia/Metal; VCL: osx
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded

Sits at ~700 MB when opened and idle.
Open test file: Memory goes from ~700 to ~830 MB
Press save: Memory goes to 1,1 GB
Close document: Memory goes down to ~700 MB

I am not sure what is expected here and if the ~700 MB memory after closing the file are acceptable or not. It is noticeable that nightly build sits at higher memory use after opening right away. The drop there goes back to the initial value.

On the bright side, I don't see much lag in saving speed. It is taking 2-3 seconds. Either this is the improved Apple Silicon architecture or LibreOffice performance improved or a combination of both.
Comment 6 Buovjaga 2025-05-12 04:07:12 UTC
In light of comment 3, what comment 5 describes is normal and healthy behaviour, so let's close.