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

Unmanaged Memory buildup when calling JpegsaveStream on several files #182

Closed
JPhillipJones opened this issue Oct 28, 2022 · 2 comments
Closed
Labels
question Further information is requested

Comments

@JPhillipJones
Copy link

Good day.
I was working in a project where I was doing some manipulation of several jpegs in a loop and I noticed that the unmanage memory seems to build up when I call the JpegsaveStream function on each. Deposing and closing the Image object doesn't seem to help. I am profiling using "dotMemory" and I can see that the unmanaged memory jumps up to about 2Gb for about 2K images. Is there something that I am missing where I can clean this up? I am loading, manipulating and saving one image at a time:

var image = Image.JpegloadStream(imageStream, null, true);
//do manupulation (hue, saturation, etc...)
image.JpegsaveStream(stream); //This is what seems to do it as if I just load and comment out this line the issue doesn't present
image.Dispose();
image.Close();

Any hints would be appreciated. Thanks.

@JPhillipJones
Copy link
Author

Nevermind, figured out I needed to be more aggressive in managing the scopes and made use of the OnPostClose method(adding delegate to dispose) to keep the memory consumption down.

@kleisauke
Copy link
Owner

kleisauke commented Nov 7, 2022

Sorry, this dropped off my radar. Glad to hear you found a solution to this.

You can also check this kind of "leaks" by setting the VIPS_LEAK environment variable or by doing NetVips.Leak = true; within NetVips - see: #114 (comment). If you procress untrusted images, you might also be interested in these tips: #96 (comment).

@kleisauke kleisauke added the question Further information is requested label Nov 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants