piggyphoto icon indicating copy to clipboard operation
piggyphoto copied to clipboard

memory leak

Open quet opened this issue 12 years ago • 2 comments

Hi! I'm having a memory leak when liveview is running, is there any way to avoid this?

Regards

code:

def liveview(): global main_surface C = piggyphoto.camera() C.leave_locked() C.capture_preview('./Ims/preview.jpg') picture = pygame.image.load("./Ims/preview.jpg") pygame.display.set_mode(picture.get_size()) main_surface = pygame.display.get_surface() pygame.display.set_caption("Vista en Vivo") while not quit_pressed(): C.capture_preview('./Ims/preview.jpg') show("./Ims/preview.jpg") pygame.display.quit() C.exit() os.remove("./Ims/preview.jpg")

quet avatar Jul 04 '12 21:07 quet

Hi.

Had the same problem. Within two minutes the preview.py went up to 60% memory consumption (from 1.6% at the start).

Apparently the problem is that in the capture_preview function cfile = cameraFile() does not get destroyed. So I deallocated it manually.

cfile.save(destpath)
cfile.__dealoc__(destpath)  # destroy cfile memory

Please bare with me, I do almost never program in python, so maybe I did something completely stupid trying to solve this. But at least it works for me (preview.py running for 2 hours, no memory leaking).

Hope this helps.

holger-hoffmann avatar Aug 30 '13 08:08 holger-hoffmann

s=self.cam.capture_preview() s.save('/tmp/preview.jpg') s.clean()

kaist avatar Apr 11 '15 09:04 kaist