-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Control number of open files in libvips' cache #315
Comments
Hello, please can you add libvips only releases the memory for *magick opened files when the file is closed, which it won't do whilst an image is in its operation cache. In addition, I believe the memory consumed by *magick images is not included in libvips' cache memory limit. |
Additional information Simple test: 'use strict';
const sharp = require('sharp');
sharp.cache(0);
console.log(process.memoryUsage());
function test() {
sharp('yBEqU6A.gif').metadata()
.then(metadata => {
console.log(process.memoryUsage());
//console.log(`${metadata.width}x${metadata.height}`);
});
}
for (let i = 0; i < 3; i++) {
test();
}
setInterval(() => {}, 60000); Result:
But if open different files, memory leak for each file. |
Thanks for the quick reply and test code. Modifying your example to also set the number of items in the cache to zero by using You'd think header-only access to a GIF file would be easy, but *magick has to decompress the whole image before it can return metadata - see http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=20017 - this animated GIF blows up to well over a gigabyte of RAM. Ouch. Perhaps sharp's cache function should also accept a boolean that, when false, turns off all libvips caching, i.e. It might be worth modifying libvips to never cache the result of the *magick loader as it has the ability to hog so much memory. |
@impomezia Have you been able to make any progress? |
The new https://github.com/lovell/sharp/blob/mind/docs/api.md#sharpcacheoptions |
v0.13.0, with improved cache control, is now available. |
Just simple open this gif file http://i.imgur.com/yBEqU6A.gif by using simple code:
It causes leak about 500 MB of memory for each open file. If 4 times to open this file, will leak about 2GB. Probably related fix https://github.com/jcupitt/libvips/pull/313
Affected current npm vesion for Windows and Ubuntu 14.04
It also may be a good idea to do
sharp.format
read/write, for example to disable magick.The text was updated successfully, but these errors were encountered: