Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encountering a memory leak when call PyDocX.to_html? #260

Open
sunglowrise opened this issue Oct 14, 2020 · 3 comments
Open

Encountering a memory leak when call PyDocX.to_html? #260

sunglowrise opened this issue Oct 14, 2020 · 3 comments

Comments

@sunglowrise
Copy link

Hi!
Encountering a memory leak when call PyDocX.to_html, is not the right way to use it ?

test example:

# python3.6 
# PyDocX == 0.9.10
def test_to_html():
    tracemalloc.start()
    snapshot1 = tracemalloc.take_snapshot()

    for i in range(10):
        with open("/tmp/test.docx", "rb") as f:
            html = PyDocX.to_html(f)
            print(html)

    snapshot2 = tracemalloc.take_snapshot()
    top_stats = snapshot2.compare_to(snapshot1, "lineno")
    for stat in top_stats:
        print(stat)
@AlexandreRozier
Copy link

AlexandreRozier commented Aug 31, 2022

We seem to have the same issue when repeatedly calling .to_hml, memory consumption keeps rising by ~ 30MB increments.

@xxxpppfff
Copy link

I seem to have the same issue and it caused the container to crash on restart

@henrymcl
Copy link

Hi! Encountering a memory leak when call PyDocX.to_html, is not the right way to use it ?

test example:

# python3.6 
# PyDocX == 0.9.10
def test_to_html():
    tracemalloc.start()
    snapshot1 = tracemalloc.take_snapshot()

    for i in range(10):
        with open("/tmp/test.docx", "rb") as f:
            html = PyDocX.to_html(f)
            print(html)

    snapshot2 = tracemalloc.take_snapshot()
    top_stats = snapshot2.compare_to(snapshot1, "lineno")
    for stat in top_stats:
        print(stat)

I'm supplying the file path to to_html and didn't see memory leaks (please take this with a grain of salt because I don't know how to properly analyze the snapshots).

Also you may want to use tracemalloc.stop().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants