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
This commit is contained in:
Tim van der Lippe
2021-10-20 14:56:34 +01:00
parent fba67a7a18
commit e6810059ef

View File

@@ -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. 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 ## Ingesting images
You can ingest a new image like so: You can ingest a new image like so: