There are memory leak phenomenon related to pdf.worker.js
See original GitHub issueBefore you start - checklist
- I followed instructions in documentation written for my React-PDF version
- I have checked if this bug is not already reported
- I have checked if an issue is not listed in Known issues
- If I have a problem with PDF rendering, I checked if my PDF renders properly in Mozilla Firefox
Description
Short description of the bug you encountered. => There are momery leak whenever I call a pdf document by react-pdf. In the end, my program suddenly stop and reload.
Steps to reproduce
Steps to reproduce the behavior:
=> I checked this result by Chrome devtool on Memory profiles VM instance. The number of VM instances start to increase whenever I reload a web page which use React-pdf module
import { Document, Page, pdfjs } from 'react-pdf'; pdfjs.GlobalWorkerOptions.workerSrc = '//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.js';
- even if I didn’t use pdfjs.GlobalWorkerOptions.workerSrc, the number of VM instances is not increased at all, but it stop and reload like above. It looks like internally increasing pdf.worker.js
import { Document, Page } from 'react-pdf'
Expected behavior
What you expected to happen? => On the moment of refreshing(F5) web page which has pdf function, react-pdf just adds another pdf.worker.js and don’t stop previous pdf.worker.js. After all, the current web page was stoped by chrome by force
Additional information
If applicable, add screenshots (preferably with browser console open) and files you have an issue with to help explain your problem.
Environment
- Browser (if applicable) [Chrome 79.0.3945.88 ]
- React-PDF version [ 4.1.0 ]:
- React version [ 16.9.0 ]
- Webpack version (if applicable) [ 4.40.2]:
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top GitHub Comments
This seems related to issue #452 Lingering Worker BLOB @oze4 has a solution and put a pull request ( #505 ) it just hasn’t been approved yet. I did my own build and tried it out. It did remove the web workers after the component unmounted.
Fixed by #505.