vue-pdf-embed icon indicating copy to clipboard operation
vue-pdf-embed copied to clipboard

memory leak

Open Marwan-Thirdwayv opened this issue 1 year ago • 2 comments

I have a list of pdfs and each time I select a pdf to open the memory increases and then i select another pdf the memory increases and do not decreases and so on till the app crashes

Marwan-Thirdwayv avatar Mar 14 '24 23:03 Marwan-Thirdwayv

Hi @Marwan-Thirdwayv,

Could you provide details on which version of vue-pdf-embed you are using and how you track memory usage?

hrynko avatar Mar 18 '24 17:03 hrynko

v.2.0.2 I have two pdfs I toggle between them but I noticed the each pdf creates an instance in the memory so the memory increases by the time . The garbage collectors works and the memory decreases but not in a good rate in case I opened many pdfs or switch between them .

This is the case I used and you can find in the dev tools of chrome in memory that each time I select a pdf a new instance created and the previous one still exists

This is screenshot for the case

Screenshot 2024-03-18 at 8 36 52 PM

This is the code sample

<template>
  <div>
    <button @click="loadPDF('pdf1')">Load PDF 1</button>
    <button @click="loadPDF('pdf2')">Load PDF 2</button>
    <div v-if="pdf">
      <pdf-embed :source="pdf" :page="1"></pdf-embed>
    </div>
  </div>
</template>

<script>
import PdfEmbed from 'vue-pdf-embed';
import 'vue-pdf-embed/dist/style/index.css'

export default {
  components: {
    PdfEmbed
  },
  data() {
    return {
      pdf: null
    };
  },
  methods: {
    loadPDF(pdfName) {
      if (pdfName === 'pdf1') {
        this.pdf = 'pdf_url_1';
      } else if (pdfName === 'pdf2') {
        this.pdf = 'pdf_url_2';
      }
    }
  }
};
</script>

Marwan-Thirdwayv avatar Mar 18 '24 18:03 Marwan-Thirdwayv

A fix for this issue has been released in v2.1.0. Thanks for reporting!

hrynko avatar Jul 23 '24 18:07 hrynko