question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Memory leak with libvips 8.9

See original GitHub issue

I have a very simple code:

import pyvips
im = pyvips.Image.new_from_file('../imgs/anoir-chafik-37957.jpg')
while True:
    im.shrink(16, 16).write_to_file('_vips.16x.png')

It constantly consuming more and more memory until it hangs up.

Screenshot 2020-01-02 at 16 23 48

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jcupittcommented, Jan 2, 2020
On each iteration, the old im is freed so memory shouldn't grow even without the fix, but it does.

That’s the libvips operation cache. It’ll keep the decoded image around in case it is needed again.

Try this:

for i in range(10000):
    print(f"loop {i} ..")
    im = pyvips.Image.new_from_file(sys.argv[1], access="sequential")
    im.shrink(16, 16).write_to_file(sys.argv[2])

The sequential tag will prevent the image being cached and it’ll be unreffed and decoded again each time. You shouldn’t see memory growth, even without that patch.

0reactions
jcupittcommented, May 5, 2020

This is all released now, so I’ll close.

Read more comments on GitHub >

github_iconTop Results From Across the Web

php libvips: memory leak and GLib errors - Stack Overflow
I have recently started using libvips for php, and I have noticed that every time a php script is run, the amount of...
Read more >
libvips
A fast image processing library with low memory needs. ... libvips 8.9 is now done, so here's a quick overview of what's new....
Read more >
README — pyvips 2.2.1 documentation
This binding passes the vips test suite cleanly and with no leaks under python2.7 - python3.6, ... For example, the libvips speed and...
Read more >
Support Advisory: Node.js v8 profile memory leak
There is a bug in the Node.js v8 profiler that causes memory leaks in Node.js versions 7 to 8.9.3. For more information, see...
Read more >
Deploy details | react-bootstrap/react-overlays - Netlify App
... MaxListenersExceededWarning: Possible EventEmitter memory leak detected. ... /sharp-libvips/releases/download/v8.9.1/libvips-8.9.1-linux-x64.tar.gz.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found