LDEV-6446 Reduce heap when thumbnailing PDFs with large page images - #63
Open
shane-tw wants to merge 1 commit into
Open
LDEV-6446 Reduce heap when thumbnailing PDFs with large page images#63shane-tw wants to merge 1 commit into
shane-tw wants to merge 1 commit into
Conversation
Thumbnails decoded the source page at full resolution before downscaling, so a first page holding a high-resolution image could use hundreds of MB of heap and OOM the rendering pod. Enable PDFRenderer subsampling so the page is decoded near thumbnail resolution, and close the document afterwards.
shane-tw
force-pushed
the
thumbnail-large-pdf-memory
branch
from
July 21, 2026 12:31
8308841 to
1736cab
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Jira: https://luceeserver.atlassian.net/browse/LDEV-6446
Problem
cfpdf action="thumbnail"renders the source page at full resolution before scaling it down to the thumbnail size. When the first page holds a high-resolution image, the full raster is decoded into heap first, so a single thumbnail request can use hundreds of MB and OOM the rendering process — even though the output is only ~140px.Change
In
PDFUtil.thumbnail(...):pdfRender.setSubsamplingAllowed(true)so PDFBox decodes the page near thumbnail resolution instead of decoding the full-size image and then downscaling.Measured effect
Rendering a 140px thumbnail of a page whose first page is a 6000×6000 image, under
-Xmx512m, using the same PDFBox 3.0.7 this extension depends on:~21× less heap, faster, identical thumbnail. A large file with a light first page was unaffected either way (+3.0 vs +3.2 MB), as expected — the cost scales with page-1 content, not file size.