jsPDF: Memory leak with lots of images
Hi!
We are creating a Phonegap app that uses jsPDF to create PDFs on the fly on users phone. We are having a problem with jsPDF documents with images. On our android app one function is creating a PDF file with lots of JPEG images, with the size of the PDF file rising to over 5 MB. It seems that there is a memory leak somewhere and if we create a few large PDF files in a row, the app crashes because it runs out of memory. I have analyzed the memory consumption with GapDebug and the problem persist even when we remove all possible references from the code after the PDF is done. The only possible solution that we could come up with that would clear the memory was to entirely restart the app…
There are maybe 10 images in our pdf. We are using Chart.js and Konva.js to create images, convert them to base64 and add to PDF, like this:
var pie = new Chart(pie_ctx).Pie(pieData, {
animation: false,
segmentStrokeColor : "#D6D6D6"
});
var image = pie.toBase64Image();
doc.addImage(image, 'JPEG', 310, 105, 100, 100);
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 21 (3 by maintainers)
Commits related to this issue
- Update addimage.js (#1115) Solution to solve memory leaks caused by big images. Is solving the issues #844 and #425 — committed to parallax/jsPDF by Uzlopak 7 years ago
- Extend Image-Plugin (#1638) * Update karma.conf.js * Merge (#7) * Update addimage.js Solution to solve memory leaks caused by big images. Is solving the issues #844 and #425 * normalize... — committed to parallax/jsPDF by Uzlopak 6 years ago
- Extend Image-Plugin (#1638) (#1648) * Update karma.conf.js * Merge (#7) * Update addimage.js Solution to solve memory leaks caused by big images. Is solving the issues #844 and #425 * n... — committed to parallax/jsPDF by Uzlopak 6 years ago
@arasabbasi,
It turns out that the problem was indeed in my code. I was not using properly the new class instance. jsPDF works as expected. Thanks for your help.
This does not help…