Reputation: 129
I am trying to read 250MB pdf file using PdfReader but it is giving memory issue.
I already tried PdfReader
with different constructor PdfReader
(filename),PdfReader
(byte[]
),PdfReader (inputstream
) but for all it is giving same error of memory problem of heap.
Is there any way to solve this issue. RAM of my PC is 4GB.
How to solve this issue so that it will work for pdf upto 1GB.
Upvotes: 0
Views: 1156
Reputation: 1617
Depending on the requirement you could use a partial read methodology which can reduce the amount of memory usage. Instead of reading the entire file into memory PdfReader (filename), PdfReader (byte[]), PdfReader (inputstream) , You could try the following instead.
new PDFReader ( new RandomAccessFileOrArray( new FileInputStream(...),null);
Also I think you wanted to know if there is a way to improve the memory usage through coding,not by increasing the heap size,for which you can use -xms and -xmx flags
Upvotes: 1