Bug 112027 - SfxCommonTemplateDialog_Impl::FillTreeBox() leaks memory
Summary: SfxCommonTemplateDialog_Impl::FillTreeBox() leaks memory
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: framework (show other bugs)
Version:
(earliest affected)
6.0.0.0.alpha0+ Master
Hardware: x86-64 (AMD64) Mac OS X (All)
: medium normal
Assignee: Julien Nabet
QA Contact:
URL:
Whiteboard: target:6.0.0 target:5.4.2
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-25 14:06 UTC by Alex Thurgood
Modified: 2017-09-05 11:57 UTC (History)
2 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 Alex Thurgood 2017-08-25 14:06:58 UTC
Description:
SfxCommonTemplateDialog_Impl::FillTreeBox() retains memory allocations indefinitely instead of releasing causing memory consumption to increase. An example of where this occurs in the UI is the Styles deck.

Steps to Reproduce:
1. Open Writer
2. Open the styles deck
3. Right click the style and click modify -> it's leaking at different places
4. Press Cancel and repeat step 3 (again leaking)

Actual Results:  
Memory leak through non-released memory

Expected Results:
Shouldn't leak


Reproducible: Always

User Profile Reset: No

Additional Info:
The problematic code as indicated by Instruments.app memory profiler appears to lie in templdlg.cxx at lines 1028-1033 :

            StyleTree_Impl* pNew = new StyleTree_Impl(pStyle->GetName(), pStyle->GetParent());
            aArr.push_back(pNew);
            pStyle = pStyleSheetPool->Next();
        }

        MakeTree_Impl(aArr);


User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:54.0) Gecko/20100101 Firefox/54.0
Comment 1 Telesto 2017-08-25 14:15:45 UTC
Confirming with 5.4.1.1
Comment 2 Alex Thurgood 2017-08-25 14:54:46 UTC
PaletteManager::LoadPallettes() is also invoked by the Edit Style dialog, and although some of the memory is released when the dialog is closed, overall memory consumption continues to increase.
Comment 3 Julien Nabet 2017-08-29 18:55:10 UTC
I submitted a patch to review here: https://gerrit.libreoffice.org/#/c/41710/
Comment 4 Commit Notification 2017-08-29 19:43:53 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=c82e5db9626e4d84300f84842b837e852be828be

tdf#112027: avoid leaks in FillTreeBox (sfx2)

It will be available in 6.0.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 5 Julien Nabet 2017-08-29 20:03:31 UTC
Alex: I'll wait for your feedback to see if it works and so to backport the patch on 5.4 branch.
Comment 6 Alex Thurgood 2017-09-05 07:27:15 UTC
Confirming fixed in 

Version: 6.0.0.0.alpha0+
Build ID: 595371e520ce4f64ad9d99a7866bdb8404271b6e
CPU threads: 4; OS: Mac OS X 10.12.6; UI render: default; 
Locale: fr-FR (fr_FR.UTF-8); Calc: group

Thanks Julien !
Comment 7 Julien Nabet 2017-09-05 08:04:57 UTC
Here's the cherry-pick waiting for review in 5.4 branch:
https://gerrit.libreoffice.org/#/c/41925/
Comment 8 Commit Notification 2017-09-05 11:57:29 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "libreoffice-5-4":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=02b95a0e8191fc560637b2fa3a62bca0bd51b9c4&h=libreoffice-5-4

tdf#112027: avoid leaks in FillTreeBox (sfx2)

It will be available in 5.4.2.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.