danfickle / danfickle/openhtmltopdf

Large Html conversion consume much memory

Open
#962 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2.2k
Forks
423
PR merge metrics
No merged PRs in 30d

Description

Hi guys,

I'm having an issue where converting a large HTML document to PDF is consuming a significant amount of memory. The HTML represents around 1200 pages, but the file size is only around 3MB.

When generating the PDF, I noticed my Java VM memory usage increasing up to around 1GB. I used a profiler to investigate further and found that a lot of byte arrays were being created during the PDF generation process. Most of the memory usage appeared to be occurring in calls to com.openhtmltopdf.css.newmatch.Condition#matches which involves java.lang.StringBuilder.toString or java.lang.StringBuilder.

![image](https://github.com/danfickle/openhtmltopdf/assets/157510283/3819928a-3a39-4bd3-ba8c-7c0777017dd8)

I'm hoping someone may be able to provide some help or insights on how I could optimize this process to use less memory. Converting such a large number of HTML pages to PDF seems to be straining the memory usage and I want to find a more efficient way to handle it.

Really appreciate it!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.