when I open a pdf with e.g. 70 pages the application memory usage increases by 100 MB and more. This happens with both implementations swt and awt. Is there a way to free up memory ?
This depends on your PDF and your usage scenario - which is not known.
jPodRenderer needs some resources but is very eager in not making hard references, e.g. on its pages or their content streams. This for example works only if you do not keep references to 70 pages yourself.
In short, we use jPod ourselves for quite large structures, but care must be taken not to keep hard references. Maybe you want to give more details…
I use jPodRenderer for a pdf viewer with a thumbnailbar so all pages got rendered when I open the document. As you say I should close the document and remove all references to it and its pages. But in case of a window resize I want to repaint the pages and I dont want to use buffered image resize options due to quality reasons. In that case I must reopen that document which may cause a delay until the pages are rendered.
There's no need to close the document (i even discourage this…). But on the other hand, if you correctly created your thumbnails you will end up with only the memory needed for the bitmaps. You see this in the code where a page tree softly references its pages and a page softly references its parsed content stream. Even more, each indirect object is implemented to hold its object weakly.
To re-render the images you will not have to reopen the document but you MAY (depending on your garbage collection so far) need to re-read and parse the content stream (behind the scenes). But thats the deal, either you cache all information or you recreate them.
Best practice may be to immediately rescale the bitmaps and re-render in a non UI thread.
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.