From e6810059efb953001cafd00d1e2accce8ac212ef Mon Sep 17 00:00:00 2001 From: Tim van der Lippe Date: Wed, 20 Oct 2021 14:56:34 +0100 Subject: [PATCH] Add warning for using multiple image pools Instantiating and using multiple image pools is not intended and can lead to memory problems. Instead, users should use a single pool and reuse that pool across all image processing. Therefore, let's add a warning in the README to specify call this out and avoid users of running into issues. Relates to #1065 --- libsquoosh/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libsquoosh/README.md b/libsquoosh/README.md index 7f4dbb82..2c067efc 100644 --- a/libsquoosh/README.md +++ b/libsquoosh/README.md @@ -22,6 +22,8 @@ const imagePool = new ImagePool(cpus().length); This will create an image pool with an underlying processing pipeline that you can use to ingest and encode images. The ImagePool constructor takes one argument that defines how many parallel operations it is allowed to run at any given time. +:warning: Important! Make sure to only create 1 `ImagePool` when performing parallel image processing. If you create multiple pools, the `ImagePool` can run out of memory and crash. By reusing a single `ImagePool`, you can ensure that the backing worker queue and processing pipeline releases memory prior to processing the next image. + ## Ingesting images You can ingest a new image like so: