PDF.js, Firefox’s built-in PDF Viewer has got huge improvements in memory consumption and speed department in version 29, it to get additional large reductions in memory consumption in Firefox 33 browser (which set to release in October) thanks to optimization work performed by Nicholas Nethercote.
While testing PDF.js with a document on Mac, Mozilla’s Nethercote has found PDF.js using highest memory and reason for that is "canvases".
"It turns out that pdf.js was intentionally caching an overly generous number of canvases (20) and then unintentionally failing to dispose of them in a timely manner. This could result in hundreds of canvases being held onto unnecessarily if you scrolled quickly through a large document. On my MacBook each canvas is over 20 MiB, so the resultant memory spike could be enormous." he explains the reason for spike in memory.
These issues have been fixed with four patches which makes PDF.js use only 10 canvases and dispose excess ones immediately.
"These patches have landed in the master pdf.js repository. They have not yet imported into Firefox’s code, but this will happen at some point during the development cycle for Firefox 33. Firefox 33 is on track to be released in mid-October".
Please share this article