https://bugs.documentfoundation.org/show_bug.cgi?id=155232

--- Comment #3 from Mike Kaganski <[email protected]> ---
Created attachment 187221
  --> https://bugs.documentfoundation.org/attachment.cgi?id=187221&action=edit
A reproducer for ever-growing memory consumption

Repro with the attached document.

It has several hundred lorem ipsum paragraphs, and a macro to produce the
problem:

===

sub oneLoop(iter)
    start = iter.getNextPara()
    Dim paragraphs(0 to 25350) ' Just the number of paragraphs in this document
    dim para as object
    para = start
    n = 0
    do while not IsNull(para)
      paragraphs(n) = para
      n = n + 1
      para = iter.getParaBefore(para)
    loop
    para = iter.getParaAfter(start)
    do while not IsNull(para)
      paragraphs(n) = para
      n = n + 1
      para = iter.getParaAfter(para)
    loop
end sub

sub testOOM
  doc = thisComponent
  iter =
doc.getFlatParagraphIterator(com.sun.star.text.TextMarkupType.PROOFREADING,
true)
  for i = 0 to 1000000
    oneLoop(iter)
  next i
end sub

===

Running 'testOOM' would result in slowly, but steadily growing memory
consumption, and will OOM eventually.

The problem is the m_aFlatParaList member in the implementation of
XFlatParagraphIterator [1]. It was introduced in the initial commits that
introduced the API: [2] [3]. It is not used elsewhere, and its use to keep
references to objects managed by UNO refcounting mechanism is questionable.

The easyhack is to just drop the list.

[1]
https://git.libreoffice.org/core/+/master/sw/source/core/inc/unoflatpara.hxx#127
[2]
https://git.libreoffice.org/core/+/677eba2322d2753951024c688d59553182bf2fbd%5E%21/
[3]
https://git.libreoffice.org/core/+/ba76230f6f677774b0d333da946a7e487acbeb0b%5E%21/

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to