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.

Memory leak - Every time a PDF is generated, the memory used increases and never comes back down.

See original GitHub issue

First, Thank you for the awesome work on this library!

Describe the bug We notice that rendering PDFs caused a memory leak in our prod environment. We dedicated some work to isulating the issue and it seems to be inside the react-pdf, because it only happens when we call it. There’s a chance I could be wrong but I havent been able to find anything else that causes this besides us calling the react-pdf library. While running react-pdf in a node server, Every time a PDF is rendered, the memory used by the app increases and never comes back down to what it was before the rendering occurred.

To Reproduce Steps to reproduce the behavior including code snippet (if applies):

  1. watch the memory used by your application that uses react-pdf.
  2. Notice how the memory used by the app increases when a PDF is rendered. and it never comes back down.

You can notice the difference better once you render over 50 or 75 documents.

HERE is a quick and easy way to reproduce it.

clone this project: https://github.com/Osuriel/react-pdf-test

the readme.me has all the steps to run it and easily monitor it.

Expected behavior The memory should eventually go back to normal after a request is made and not increase continually.

Screenshots before rendering pdfs: image

after rendering 100 pdfs, and waiting for a while: image

Desktop (please complete the following information):

  • OS: MacOS, Linux
  • "@react-pdf/renderer": "1.6.4"
    

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:8
  • Comments:14

github_iconTop GitHub Comments

5reactions
victorlpgazollicommented, Feb 16, 2021

Still not working ²

3reactions
em-wucommented, Oct 21, 2019

I also have a problem, which is probably related to a memory leak. When I’m rendering document to the file for the first time - everything is ok. Any second and next attempt (for example, after changing the list of maped children in Page component) is unsuccesful - there is an error. Looks like the memory is not erased after first rendering.

Child already has a parent, it must be removed first.

The above error occurred in the <VIEW> component: in VIEW (created by ProjectMap) in VIEW (created by ProjectMap) in VIEW (created by ProjectMap) in PAGE (created by ProjectMap) in ProjectMap in DOCUMENT

Uncaught (in promise) abort() at Error at jsStackTrace (ROOT\node_modules\yoga-layout-prebuilt\yoga-layout\build\Release\nbind.js:443:15) at stackTrace (ROOT\node_modules\yoga-layout-prebuilt\yoga-layout\build\Release\nbind.js:453:14) at Object.abort (ROOT\node_modules\yoga-layout-prebuilt\yoga-layout\build\Release\nbind.js:9808:182) at _abort (ROOT\node_modules\yoga-layout-prebuilt\yoga-layout\build\Release\nbind.js:585:20) at ge (ROOT\node_modules\yoga-layout-prebuilt\yoga-layout\build\Release\nbind.js:2905:136) at Vd (ROOT\node_modules\yoga-layout-prebuilt\yoga-layout\build\Release\nbind.js:2443:101) at ec (ROOT\node_modules\yoga-layout-prebuilt\yoga-layout\build\Release\nbind.js:1928:23) at kc (ROOT\node_modules\yoga-layout-prebuilt\yoga-layout\build\Release\nbind.js:1951:86) at Ig (ROOT\node_modules\yoga-layout-prebuilt\yoga-layout\build\Release\nbind.js:3444:37) at hm (ROOT\node_modules\yoga-layout-prebuilt\yoga-layout\build\Release\nbind.js:4785:228)

I’m using v1.6.7.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Memory leak - Every time a PDF is generated, the memory used ...
Memory leak - Every time a PDF is generated, the memory used increases and never comes back down.
Read more >
IronPDF Causing a Memory Leak - Stack Overflow
I noticed over time, total memory used by the process increases and ultimately crashes. Further investigation showed the unmanaged memory keeps ...
Read more >
How To Detect and Prevent Memory Leaks | Scout APM Blog
Memory leak is the gradual loss of available computer memory when a program repeatedly fails to return memory it obtained for temporary use....
Read more >
3 Troubleshoot Memory Leaks - Java - Oracle Help Center
This chapter provides some suggestions for diagnosing problems involving possible memory leaks.
Read more >
Fix memory problems - Microsoft Edge Development
The performance of a page gets progressively worse over time. This is possibly a symptom of a memory leak. A memory leak is...
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