Issue 48642 - Memory leak after making Writer tables via PyUNO session
Summary: Memory leak after making Writer tables via PyUNO session
Alias: None
Product: Writer
Classification: Application
Component: code (show other issues)
Version: OOo 1.1.4
Hardware: All All
: P3 Trivial (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
Depends on:
Reported: 2005-05-03 16:51 UTC by geoffteale
Modified: 2017-05-20 11:25 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---

java example (9.33 KB, text/plain)
2005-05-11 09:18 UTC, Oliver Specht
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description geoffteale 2005-05-03 16:51:39 UTC
It seems that when you run as a "server" using the "accept"
command line it is possible to make it leak memory by repeatedly running a
Python script that connects with PyUNO, writes some tabular data into a Writer
document, and then saves it as a PDF file.  Our code is leaking around 1MB per
script, but here is an example that seems to cause soffice.bin to leak around
about 0.2MB per invocation:

import uno
from import PropertyValue
from import CloseVetoException
from import DisposedException
from import IOException
from import NoConnectException
from import XModifyListener
import unohelper

if __name__ == "__main__":
    local_context = uno.getComponentContext()
    local_service_manager = local_context.ServiceManager
    resolver = local_service_manager.createInstanceWithContext(
        '', local_context)
    connection_string = \
    remote_context = resolver.resolve(connection_string)
    remote_service_manager = remote_context.ServiceManager
    desktop_class = ''
    desktop = remote_service_manager.createInstanceWithContext(desktop_class, 
    properties = ()
    url = "private:factory/swriter"
    document = desktop.loadComponentFromURL(url, "_blank", 0, properties)    
    text = document.Text
    cursor = text.createTextCursor()
    text.insertString( cursor, "Hello World", 0 )

    table_count = 0
    while table_count < 5:
        table = document.createInstance( "" )
        text.insertTextContent( cursor, table, 0 )
        for i in range(1, 41):
            for letter in ("A", "B", "C", "D"):
                name = "%s%i" % (letter, i)
                cell = table.getCellByName(name)
                cell_cursor = cell.createTextCursor()
                cell .setString(name)
        table_count += 1

    export_format = "writer_pdf_Export"
    export_properties =  (PropertyValue('FilterName', 0, export_format, 0),
                          PropertyValue('Overwrite', 0, True, 0),)
    export_url = unohelper.systemPathToFileUrl("/home/gteale/foo.pdf")
    document.storeToURL(export_url, export_properties)
    except CloseVetoException:
Comment 1 kay.ramme 2005-05-04 15:23:21 UTC

how are you measuring the leak(s)? Can you reproduce it with a BASIC script
running in process?
Comment 2 geoffteale 2005-05-04 16:17:08 UTC
The real-world case where we see it is infact _always_ with BASIC code running
inside Writer.  We invoke a function that connects to a database and writes
content out into tables on the page.  We only invoke that function via PyUno.

The exmple in PyUno (above) is just the simplest case I could produce to achieve
a similar effect.  To be clear, as far as I can tell it's the writing of tables
that is causing the leak.
Comment 3 kay.ramme 2005-05-10 17:49:16 UTC
It IMHO already leaks when just opening&closing writer documents. At least on my
Linux box the data segment is overall growing. Andreas, please take care of this.
Comment 4 andreas.martens 2005-05-11 07:57:57 UTC
Oliver, please check, if there's a memory leak and how we can avoid this.
Comment 5 Oliver Specht 2005-05-11 09:18:41 UTC
Created attachment 26007 [details]
java example
Comment 6 Oliver Specht 2005-05-11 09:22:33 UTC
Executing the attached java code in a Windows non-pro on m100 costs about 1MB.
It creates 5 documents, fills with tables and stores it to pdf.

Without the tables it costs about 300 KB.

Skipping PDF export doesn't change anything. 
Comment 7 Marcus 2017-05-20 11:25:02 UTC
Reset assigne to the default "".
Comment 8 Marcus 2017-05-20 11:25:48 UTC
Reset assigne to the default "".