pdf2json icon indicating copy to clipboard operation
pdf2json copied to clipboard

how to free memory used by pdf2json?

Open zihuyishi opened this issue 8 years ago • 3 comments

I have a server that run four process to handler client side pdf. I found that when client side send a 10mb pdf file, one process will used 400mb memory and never free it. When run it for long time and receive some big pdf, it will take me about 4gb memory, and make other app down. I have a test code like this

const pdfParser = new PDFParser(this, 1);

pdfParser.on('pdfParser_dataReady', pdfData => {
    console.log('--------------raw-----------------');
    console.log(pdfParser.getRawTextContent());
});

pdfParser.loadPDF('/Users/saye/Downloads/Gradle_Recipes_for_Android.pdf');
let server = http.createServer((req, res) => {
    res.write('hello');
    res.end();
});
server.listen(2345);

so what should I do to make memory free

zihuyishi avatar Feb 20 '17 02:02 zihuyishi

I created a new pdftojson based on xpdf in c. Perhaps it will work better for you? https://github.com/ldenoue/pdftojson

On Feb 20, 2017, at 3:24 AM, saye [email protected] wrote:

I have a server that run four process to handler client side pdf. I found that when client side send a 10mb pdf file, one process will used 400mb memory and never free it. When run it for long time and receive some big pdf, it will take me about 4gb memory, and make other app down. I have a test code like this

const pdfParser = new PDFParser(this, 1);

pdfParser.on('pdfParser_dataReady', pdfData => { console.log('--------------raw-----------------'); console.log(pdfParser.getRawTextContent()); });

pdfParser.loadPDF('/Users/saye/Downloads/Gradle_Recipes_for_Android.pdf'); let server = http.createServer((req, res) => { res.write('hello'); res.end(); }); server.listen(2345); so what should I do to make memory free

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

ldenoue avatar Feb 20 '17 09:02 ldenoue

@ldenoue thank you, I will try it.

zihuyishi avatar Feb 23 '17 01:02 zihuyishi

you can try pdfParser.destroy() to free the memory

BigWolf286 avatar Sep 24 '19 01:09 BigWolf286