jbaiter / gphoto2-cffi

Python bindings for libgphoto2 with an idiomatic API
GNU Lesser General Public License v3.0
38 stars 17 forks source link

`Camera.capture()` has a memory leak issue #26

Open define-private-public opened 7 years ago

define-private-public commented 7 years ago

This is related to some of my comments near the bottom of #21, specifically this post: https://github.com/jbaiter/gphoto2-cffi/issues/21#issuecomment-298205430

After the "fix," I mentioned i suspected that the capture() method of Camera might also have a memory leak. Here is the code that I ran:

import gphoto2cffi as gp

# Get the camera
cam = gp.Camera()

# Infinite loop
while True:
    _ = cam.capture()

I ran that code for about 15 minutes. My my system's RAM usage for that program jumped from 0.1% to 0.4% for that process. While that is very tiny it could cause a lot of problems for anyone who wants to do tethered capturing over a very long period of time.

I'm looking at a fix like the one that I linked above, I'll try to get a pull request to you tomorrow that fixes both.

multiholle commented 7 years ago

Was this fixed here? https://github.com/jbaiter/gphoto2-cffi/pull/27

define-private-public commented 7 years ago

Not fully unfortunately. The one regarding get_preview() was, but this one with capture() has been slightly trickier to track down. As stated in the above comment, it is a very tiny memory leak, and would only impact people who want to do capturing over a very long period of time.

multiholle commented 7 years ago

I'm building a photobooth for my wedding. The preview would be good for the people to position themselves. I was planning to keep the preview running. I have to check if I run into problems.

define-private-public commented 7 years ago

Preview should be fine. If you look at my linked issue, there should be a sample Qt app in it that shows the preview. Try that out and see if you get any memory leaks from it.

Memory leaks may arise from the use of capture(), but they are stupidly tiny.