question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Possible memory leak following rendering

See original GitHub issue

First off: awesome work with WeasyPrint, it’s super great !

We’re using WeasyPrint under django and are experiencing a memory usage issue. if we make a big pdf (~360 pages with graphics) at the moment we do document.render() the memory jumps up a lot (1.4G), the problem is that once the pdf is made and the request is finished the webserver is still hanging onto that slice of memory, it seems never to be released.

Is anyone aware of memory release issues using WeasyPrint ? the relevant code is here:

#low mem here
html = weasyprint.HTML(StringIO(html_string.encode('utf-8')), encoding='utf8', base_url='file://')
#low mem here
html.write_pdf(target=out_filename)
#high mem here
del html
gc.collect()
#high mem here still

maybe we should be spawning a new process to run WeasyPrint in for such large PDFs ? we’ve tried calling gc.collect() to no effect.

any ideas would be appreciated, cheers

-ivan

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:2
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
jimrcommented, Jun 2, 2017

@excieve FWIW we pass --maxtasksperchild 10 to our celery worker command to avoid ever-growing memory footprint for workers using WeasyPrint. This restarts workers every ten tasks which works pretty well for our workload and means we don’t have any issues with memory consumption any more.

0reactions
excievecommented, May 30, 2017

Thank you @liZe and @SimonSapin for looking into it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hunting memory leaks in a server side rendered React ...
Our memory leak was caused by reselect and with the bad usage of styled-components, both problems were found by using Chrome DevTools. Backstory....
Read more >
Exploring Memory Leaks in Flutter from the Rendering Process
This article analyzes the memory allocation of Flutter, explains the rendering process, and proposes a solution for memory leaks based on ...
Read more >
Re: Memory Leak in MFR during Render - 12592344
I think there is a fundamental memory leakage problem because renders become slower each subsequent time, requiring a reboot (simple restart of ...
Read more >
Fixing memory leaks in web applications | Read the Tea Leaves
(Of course, a server-rendered website can also leak memory on the server side. But it's extremely unlikely to leak memory on the client...
Read more >
Massive Memory Leak When Rendering? - Bug - Shotcut Forum
After about 5 hours of rendering, the memory use of melt.exe has ... is using over 57 GB of RAM (using all 16...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found