vue-pdf-embed
vue-pdf-embed copied to clipboard
memory leak
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
Hi @Marwan-Thirdwayv,
Could you provide details on which version of vue-pdf-embed you are using and how you track memory usage?
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
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>
A fix for this issue has been released in v2.1.0. Thanks for reporting!