Best Practices for managing memory in react

Using PDFJS Webviewer in React, what are some tips/best practices for managing memory when dealing with a single webviewer and multiple pdf documents.

Currently our memory usage grows with each document switch, even if returning to a document that had already been loaded.

Hi there,

We recommend using the loadDocument API to open every new document with the same instance.

Please see this guide for more details:

Best regards,

Kevin

I’ve followed those where appropriate, but wondering how else to prevent memory from growing.

Hi there,

There is a dispose method under the UI namespace that you could try using, if it is not happening automatically:

best regards,

Kevin