question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Huge memory usage on toBuffer

See original GitHub issue

I’m working on dynamically generated documents. There is a lot of images created in some promises, and in many cases toBuffer method consumes way too big amount of memory. Is there any way to use streams in my case? In many scenarios total memory usage (when toBuffer is initialised) exceeds 8gb code example:

await Promise.all(promises).then(data => data.forEach(item => section.children.push(...item)));
// report-generator | Total Memory used: 1397.78 MB

doc.addSection(section);
// report-generator | Total Memory used 4: 1523.53 MB

let buffer = await docx.Packer.toBuffer(doc);
// report-generator | Total Memory used 5: 2590.27 MB

as I know in the history there was an option of creating a stream using Packer.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dolanmiucommented, Sep 1, 2021

Probably could work, if you could make a PR with it, that could be nice

It might complicate the API which is my concern, now having two ways of achieving something

0reactions
vooitcommented, Jun 3, 2022

I gave up… And with my friend we’ve wrote C++ app to combine multiple docx files So i create a lot of small files nad in. the end I merge them into one. I was able to do so bcs Im generating everything on cloud server as side process

Read more comments on GitHub >

github_iconTop Results From Across the Web

NodeJS Sharp Node Package Memory Consumption Issue
The problem is Node process keeps adding the processed file in memory and never releases it. As a result, amount of memory consumed...
Read more >
Memory runs full over time, high "buffer/cache" usage, low ...
Whenever I reboot my laptop, everything runs amazingly and I have a maximum of 40% memory usage (out of 8GB). However over time...
Read more >
Potential buffer overflow and high memory usage in IBM HTTP ...
This APAR resolves a problem with SetEnvIf usage potentially leading to buffer overflow or high memory usage in IBM HTTP.
Read more >
virtual machines - RAM usage is high altough there is no high ...
Our virtual server has Centos 6 OS. When I look to buffer/cache usage it seems less at first line. Proccesses're not use to...
Read more >
Why the Buffer and Cache Occupy Too Much Memory ... - 华为云
When querying the system memory usage using free after the Linux ECS ... a high cache memory usage does not affect the system...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found