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

Memory Leak using node #3051

Open
carlosmeds opened this issue Jan 30, 2025 · 4 comments
Open

Memory Leak using node #3051

carlosmeds opened this issue Jan 30, 2025 · 4 comments

Comments

@carlosmeds
Copy link

carlosmeds commented Jan 30, 2025

Describe the bug
Unfortunatelly, using React-PDF/renderer is giving us a memory leak. We tried to remove all listeners, tried different methods, like renderToStream, renderToBuffer and updateContainer but it keeps increasing memory usage.

Desktop (please complete the following information):

  • OS: linux
  • React-pdf version 4.1.6
@diegomura
Copy link
Owner

I'll need a way to replicate this

@nnaku
Copy link
Contributor

nnaku commented Feb 11, 2025

There seem to be still or new memory leak in loadYoga

Image

Retained size of instancePromise is getting out of hand.

We are using react-pdf in backend and rendering pdf's on the fly just simply callingawait renderToBuffer(<ThePdf {...props} />)

@nnaku
Copy link
Contributor

nnaku commented Feb 12, 2025

I'll need a way to replicate this

Leak will show up at debugger with this.

import React from "react";
import { renderToBuffer } from "@react-pdf/renderer";
import { Quixote } from "./pdf.js";   // copy from https://react-pdf.org/repl

for (const i of Array(100).keys()) {
  await renderToBuffer(<Quixote />);
}

@nnaku
Copy link
Contributor

nnaku commented Feb 12, 2025

downgrading yoga-layout to 3.0.4 removes the memory leak

❯ yarn why yoga-layout
└─ @react-pdf/layout@npm:4.2.2
   └─ yoga-layout@npm:3.2.1 (via npm:^3.2.1)
Image

and after setting resolution for yoga-layout: 3.0

❯ yarn why yoga-layout
└─ @react-pdf/layout@npm:4.2.2
   └─ yoga-layout@npm:3.0.4 (via npm:3.0)
Image

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

No branches or pull requests

3 participants