I read 100 jpeg images in a loop and extract different areas from them.
Loop contents:
VImage in = VImage::new_from_file(impath.c_str(),
VImage::option()->
set( "access", VIPS_ACCESS_SEQUENTIAL ) );
VImage out = in.extract_area(x0, y0, x1 - x0, y1 - y0);
cout << out.avg() << endl;
Or the same thing in python:
img_full = pyvips.Image.new_from_file(impath, access='sequential')
img = img_full.extract_area(x0, y0, x1 - x0, y1 - y0)
print(img.avg())
I watch RSS, physical memory usage. It starts from around 40MB and then with each image it grows.
Here is the graph for images 4X the original size with the same crop's origin, width/height.
Why does it happen ? Is there a leak going somewhere ?
When I set a flag to trace leaks, pyvips.base.leak_set(1)
, I get about 60 MB reported. Also I used cgroups to limit a physical memory for a process to 100 MB. Vips is able to run, without crashing, but is slower.
For comparison, the similar operations in OpenCV consume almost a constant amount of RSS, 140 MB or 300 MB depending on the image size. For my experiments, vips wins several times in CPU time, but looses several times in memory.
pyvips version: 2.0.4
libvips version: 8.6.1