foliojs / pdfkit

A JavaScript PDF generation library for Node and the browser
http://pdfkit.org/
MIT License
9.84k stars 1.15k forks source link

Please use lru to cache font layout to fix memory leak #1527

Open abihf opened 3 months ago

abihf commented 3 months ago

Bug Report

Description of the problem

There's memory leaks when using custom fonts with huge data. I can disable fontLayoutCache but the performance is 3x slower.

I think we should use lru instead of simple object here

Code sample

//TODO:

Your environment

blikblum commented 3 months ago

Can you provide a PR?