for my latest project, I use a camera module version 2 on a Raspberry model 3. I use the PiCamera module in Python to take simple photos. Operating system is Raspbian Lite.
I have noticed that for each photo stored on the hard disk, the same amount of filesize is allocated in the RAM. However, it is never cleared. This already lead to an out-of-memory crash. Here is what I tested:
- Take 50 pictures => Outcome: size of 50 images allocated in RAM
- Take 50 pictures again and overwrite first 50 pictures => size of 50 images allocated in RAM
- Take 100 pictures, overwrite previous 50 pictures => size of 100 pictures allocated in RAM
- Take 1000 pictures => RAM usage piles up until only around 40-50 MB are left. While still taking more pictures, the RAM level seems to stay like that
Here is a code snippet of what I am doing. As far as I am concerned, there is no command to close or cleanup the camera object after taking a picture.
Code: Select all
import time
import picamera
# Camera setup
camera = picamera.PiCamera()
camera.rotation = 180
camera.hflip = True
camera.resolution = (2592, 1944)
camera.exposure_mode = 'sports'
for c in range(0, 100):
camera.capture('/home/pi/images/' + str(c).zfill(4) + '.jpg')
print 'Capturing photo #' + str(c).zfill(4)
time.sleep(0.5)
- knucKles