-
-
Notifications
You must be signed in to change notification settings - Fork 70
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
Ram leak? #716
Comments
I have too memory leak. |
Same here, even clearAllCache() doesnt work. |
I confirm the issue, RAM never get released, with 0.1.44 |
I tested on I managed to narrow it down to calling I'm talking about 60~80MB of memory increase per render of a 8MB PNG. And yes I also tried Since this package has bindings to a native binary, it makes sense nodejs does not detect the memory leak. I have not seen others report this yet, so figured I would report my findings. Hope it gets fixed sometime, until then pinning version to |
@Brooooooklyn If you could fix this, people would be very grateful. It's literally unusable unless you pre-generate images. There is 100% a leak and if you know where it is, that would be helpful for someone making a fix. |
Line 259 in f3a699b
Is the usage of noop here the cause? |
I'm looking into this issue, what kind of image do you generate with |
In my case, a canvas of size 3000x925. Method or attribute used (maybe usefull for a reproduction code): Then I call I have 3 registered fonts. |
@SteadEXE thank you, I'll try |
Does anyone actually catch a real-world oom? I'm wondering if the RSS is allocated memory, not the actually used memory. |
In my case, the process eat all the available RAM on Windows, until system itself runs out of memory. |
After some test, I can confirm after generating 1000+ images on my side I reach 4.5GB+ RAM, while I never go over 300 MB in 0.1.37. |
The issue is an actual memory leak, as Bun.gc(true) would clear eg. large arrays or other things. Just simply generating a few captchas on-demand is basically impossible, which was how I found it.
|
Can you try this version to see if it has fixed your issue? https://github.com/Brooooooklyn/canvas/releases/tag/v0.1.48 ? |
Edit: It's only leaking when you encode with png, webp was fixed. Not sure about the others. For me, it seems like it's still leaking the same amount on 0.1.48, or in any case, it's still leaking regardless.
|
@7te3ep I can't reproduce the leak with the code: import { createCanvas } from './index.js'
async function test() {
const canvas = createCanvas(2560, 1920)
const ctx = canvas.getContext('2d')
ctx.fillStyle = "black";
ctx.fillRect(0, 0, canvas.width, canvas.height);
await canvas.encode("webp", 100);
}
for (let i = 0; i < 5000; i++) {
await test();
global?.gc?.()
console.info(process.memoryUsage().rss / 1024 / 1024 + " MB");
}
setInterval(() => {
console.info(process.memoryUsage().rss / 1024 / 1024 + " MB");
}, 1000); On my MacBook, the output was like:
As you can see, the memory usage is very stable |
I'm not sure if you were replying to me, but it's leaking with png, not webp. webp is fine now. |
Confirmed that PNG is still leaking, I will fix it immediately. |
For me it looks like the issue is fixed, thank you 🥇 |
Seems like if I don't use clearAllCache() then the memory goes up every time something is rendered.
The text was updated successfully, but these errors were encountered: