Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve memory usage #233

Closed
wants to merge 1 commit into from
Closed

improve memory usage #233

wants to merge 1 commit into from

Conversation

denislavski
Copy link
Contributor

A use case required combining just above 1000 PDF files (1 page each) and the gem struggled.
I noticed that CombinePDF::PDF#to_pdf instantiates way to many String objects.
Benchmarks showed these objects occupied 16GB of memory (in the case from above) while after the patch thIs number went down to 258MB.

Changes:
Instantiates fewer String object by appending to existing strings which it is more performant than using the + operator.
Appends to the last item in the array instead of popping and adding another one back.
Extracts a constant.

Instantiates fewer String object by appending to existing ones.
Appends to the last item instead of popping and adding back.
Extracts a constant.
@denislavski
Copy link
Contributor Author

Related to: #224

@Koinly Koinly closed this by deleting the head repository Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants