Hi all,
we have a java web app rendering document previews as PDF using com.groupdocs:groupdocs-viewer:24.12 as follows
FileType fileType = FileType.fromExtension(extension);
LoadOptions loadOptions = new LoadOptions(fileType);
loadOptions.setSkipExternalResources(true);
try (Viewer viewer = new Viewer(inputStream, loadOptions);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
PdfViewOptions pdfViewOptions = new PdfViewOptions(() -> byteArrayOutputStream);
pdfViewOptions.setDefaultFontName(DEFAULT_FONT_NAME); // "Noto Serif CJK SC"
viewer.view(pdfViewOptions);
return byteArrayOutputStream.toByteArray();
}
After some time the JVMs OOM, the heapdump reveals
AppClassLoader
└─ class com.groupdocs.viewer.internal.c.a.pd.internal.l7v.lk
└─ lI (static field)
└─ …ms.System.Collections.Generic.lf
└─ Object[] → 13.2 GB
which is a static field rooted in the App ClassLoader never unloaded. The memory is reachable only through the static field, no app references, so it cannot be freed releasing app state.
Please advise if 13.2 GB main memory are a library requirement to render documents, as it feels slightly inappropriate.
Please advise if this is a known issue already fixed in versions > 24.12, which might be outdated.
If this is an internal cache, it should rather use weak/soft ref or bounded eviction so the JVM can reclaim memory instead of OOMing.
Please advise if there are options and ways to configure and limit the heap used by the library to a reasonable limit, e.g. 1-4 GB?
Further details available on request.
Best Regards!