base64-arraybuffer icon indicating copy to clipboard operation
base64-arraybuffer copied to clipboard

Memory leak in encode

Open murugu-21 opened this issue 3 years ago • 2 comments

We internally used this package for encoding/decoding large pdf files and noticed our instance crashing on around 2gb of files. The instance had free memory of 12gb! After hours of debugging we narrowed it down to the encode function of this library. I read the encode function code and tried to figure out why? But couldn't find a leak. But from our testing and debugging, I am sure there's a memory leak in encode function (in nodejs v8) @niklasvh

murugu-21 avatar Jan 10 '23 12:01 murugu-21

I think I'm also facing a memory leak with this library, did you find a solution for it? @murugu-21

carmenchapa avatar Feb 10 '23 10:02 carmenchapa

Yes, just use the inbuilt Buffer library like below

const fileContent = 'abc';
const fileBase64 = Buffer.from(fileContent).toString('base64'); // same as encode(fileContent)
Buffer.from(fileBase64, 'base64'); // same as decode(fileBase64)

Hope it helps!

murugu-21 avatar Feb 10 '23 10:02 murugu-21