piggyphoto
piggyphoto copied to clipboard
memory leak
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")
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.
s=self.cam.capture_preview() s.save('/tmp/preview.jpg') s.clean()