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

v1.0.1 - Apparent memory leak with async output in some conditions #145

Open
mpaperno opened this issue Aug 14, 2023 · 1 comment
Open

Comments

@mpaperno
Copy link

mpaperno commented Aug 14, 2023

Hello!

I've been tracking down a memory leak with a program I work on which uses skia-canvas. I tracked the issue to s-c and I seem to have narrowed it down to some difference in v1.0.1 vs. 1.0.0.

I've also narrowed down that it only occurs when:

  • Async toBuffer('png') is used (I haven't tested other output formats)
  • toBufferSync('png') with canvas.gpu = false

So using async version causes a leak regardless of GPU option, but using the sync version and GPU rendering does not.

More specifically, seems to be caused by 68bef1b. At the commit prior to that I cannot recreate it (detailed observations below). Why this has anything to do with async operation, I have no idea, but my results were clear and reproducible.

I'm attaching my test script (and a basic package file). It works with skia-canvas versions going back to at leat 0.9.25 and has no other dependencies. Async and GPU (for v1+) can be en/disabled on command line or with variables at the top. The image output is discarded, no files are written... there's a little running time counter to show the script is working. CTRL-C to exit.

Copied from the comments in the test script, here are my observations (memory counts are just for reference, YMMV on various systems of course).

// Observed memory (measurements from "active set" counter in Win10 Task Manger > Details):
//
// v1.0.1rc1 - 1.0.1:
//         ASYNC on,  GPU any == LEAK, steady increase until exit
//         ASYNC off, GPU off == LEAK,  "
//         ASYNC off, GPU on  == hovers ~65MB
// ---------------------------------------
// v1.0.0 - skia-canvas@9f35d190122e1aaa85469d2a74044ee026071e47
//         ASYNC on,  GPU off == hovers ~45MB
//         ASYNC on,  GPU on  == hovers ~160MB
//         ASYNC off, GPU off == hovers ~43MB
//         ASYNC off, GPU on  == hovers ~65MB
// ---------------------------------------
// v0.9.25 - v0.9.30:
//         ASYNC on or off  == climb to just < ~300MB then sharp reset to ~60MB, repeat
// ---------------------------------------

My test system is Windows 10, Intel CPU (no GPU), NVIDIA RTX2080Ti with Studio driver 536.40 (first reported by another user with AMD CPU, NVIDIA RTX3xxx on Win10). Node v18.16.0. I haven't tried it on a system with non-supported GPU yet, but that's on my list.

If anyone else cares to give the test script a shot with the different settings, that'd be great. I spent quite a while verifying my results, but ya never know. It can take a bit of time before the leak is obvious, patience and comparison to "non-leaky" results are helpful.

Please let me know if I can provide any further details.

Thanks!
-Max

skia-canvas-mem-test.zip

PS. I also posted the script as a Gist, to see w/out a download. Not much to it.
https://gist.github.com/mpaperno/75284be4de0ef2006d876773507e6ddf

@Santas
Copy link

Santas commented Aug 28, 2024

Just FYI for others that considered holding off updating, because of this issue - test on your machines.
I wasn't able to reproduce the issue on Mac from the gist with async=on, gpu=any. Also we don't have an issue running in production on Windows machines with steady load generating about 17M images/day - we use async and gpu off.

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

No branches or pull requests

2 participants