Optimize Jasper exporter memory usage and reduce PDF size#3624
Optimize Jasper exporter memory usage and reduce PDF size#3624sebr72 merged 2 commits intomapfish:masterfrom
Conversation
core/src/main/java/org/mapfish/print/output/JasperReportPDFOutputFormat.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/mapfish/print/output/JasperReportPDFOutputFormat.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/mapfish/print/output/JasperReportPDFOutputFormat.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/mapfish/print/output/JasperReportPDFOutputFormat.java
Outdated
Show resolved
Hide resolved
|
@sbrunner Could you please confirm this strategy for clearing cache is not conflicting with other parts of MFP, in case I forgot something. |
|
@sebr72 difficult to be certain, for me, we should go ahead with that :-) |
b9d7e44 to
b101a1c
Compare
|
I have coded your suggestion and added a test, not sure if its the most relevant. It seems ok but i'm not an expert. This MR in my opinion is a small optimization but can be usefull. |
b101a1c to
0a77c1d
Compare
|
@arnaudboudier-sogelink What do you mean by MR in this sentence: |
sebr72
left a comment
There was a problem hiding this comment.
Great work. Thanks.
I noticed you used MR Corrections as a commit comment, which hides the value of the content of your commit. Could you please amend it to something more specific (e.g add test to demonstrate pdf memory size impact) ?
0a77c1d to
f3504c4
Compare
|
@sebr72 I have change the text commit |
We use a WeakHashMap in JRPdfExporter as an image cache to allow it to be automatically cleared when memory becomes low, while preserving the functionality (which helps produce a smaller PDF).
Test added : JRPdfExporterWeakHashMapTest explains that:
JRDExporter uses loadedImagesMap to save reference of a image that will be put into the pdf. So when the pdf is exported, references are used inside the pdf to point to the same image and prevent to duplicate the image into the pdf.