Possible memory leak following rendering
See original GitHub issueFirst 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:
- Created 9 years ago
- Reactions:2
- Comments:14 (7 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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.Thank you @liZe and @SimonSapin for looking into it!