question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Memory leak with lots of images

See original GitHub issue

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);

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:21 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
orodriguez2commented, Mar 14, 2017

@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.

1reaction
VilleImmonencommented, Oct 31, 2016

This does not help…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bug report - Windows 10 "Photos" app memory leak
Bug report - Windows 10 "Photos" app memory leak. Double-click on a file in a directory with lots of images; Wait for Photos...
Read more >
Memory leak with lots of images · Issue #844 - GitHub
It seems that there is a memory leak somewhere and if we create a few large PDF files in a row, the app...
Read more >
Memory leak when loading images - Stack Overflow
This code, which is based on this answer, solved it for me var fileQueue = []; var lock = false; var img =...
Read more >
WidgetKit Memory Leak on Images | Apple Developer Forums
Hello, I'm experimenting with the WidgetKit template and noticed that adding Images seems to generate a memory leak that terminates my app after...
Read more >
Photoviewer part 3 – Fixing memory leaks - Blog
What I did was change the image cache in such a way that it stores a WeakReference to the various images instead of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found