React: PDFTron Memory Leak

Product: @pdftron/webviewer

Product Version: 8.4.0

Please give a brief summary of your issue:
(Think of this as an email subject)
Closing a webviewer instance does not clean up all the memory

Please describe your issue and provide steps to reproduce it:
(The more descriptive your answer, the faster we are able to help you)

Currently we have an application that requires up to open up multiple webviewer instances as the user moves around the application. This is because the webviewer iframe needs to be tethered to different html elements depending on the workflow.

The problem this creates is that we have to close and reopen webviewers overtime. This leads to a memory leak, where everytime we close a webviewer, not all the memory is cleaned up.

A super simple way to recreate this bug is click on a button that initializes a webviewer, close the webviewer and make sure to run
webViewer.instance.Core.documentViewer.dispose();
webViewer.instance.UI.dispose();

Please provide a link to a minimal sample where the issue is reproducible:

Hello John,

Welcome to the PDFTron community forum!

It is generally recommended to re-use the WebViewer instance as Chrome caches the files automatically.

Let me know if these work for you!

Best regards,
Tyler Gordon
Web Development Support Engineer
PDFTron

For reusing the webviewer instance, is there a good way to tether it to different html elements as the user moves throughout the App? We have tried to keep it in a react context provider but haven’t had any luck. I’ll see if doing dispose on Core gives us an improvement

Hello john,

We have another forum post on handling the reuse of WebViewer here: Reuse of existing viewer instance
It recommends hiding/showing WebViewer when needed. This could be tied to an element near the top level of the DOM, and using CSS you could move it to the correct location.

Best regards,
Tyler Gordon
Web Development Support Engineer
PDFTron

Hello,

We are having the same issue.

We have many users reporting memory problems on their browsers. Would be awesome if you could make a sort of solution to clear the memory when the viewer is unmounted.

We have many use-cases where we cant re-use the viewer instance and so we need to create news instances.

This is a critical issue for us, we hope we can get a quick answer from PDFTron.

Thanks.

@tgordon

Hi @tgordon, do you have any news?