Open why-myles opened 7 months ago
Thanks for reporting this. Running the latest versions of the software, we think it's actually leaking a file descriptor rather than memory and are working on a fix.
Should be fixed by: https://github.com/raspberrypi/picamera2/pull/960
RPi4, Arducam 64MP Still facing the exact same issue like above.
RPi4, Arducam 64MP Still facing the exact same issue like above.
Hi, can you confirm what version of Picamera2 you are running. Please confirm your OS version (cat /etc/os-release
), kernel version (uname -a
) and the amount of CMA you have (grep Cma /proc/meminfo
). Also, how much RAM does your Pi have? Finally, please attach the smallest and simplest script that you can that will reproduce the problem you are having. Thanks.
Hi, thx for the fast response.
git head is c4d6aab91013c6a5567297b8643c87692fb1f1bc of the next branch
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)" NAME="Debian GNU/Linux" VERSION_ID="12" VERSION="12 (bookworm)" VERSION_CODENAME=bookworm ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/"
Linux fotobox 6.1.0-rpi7-rpi-v8 #1 SMP PREEMPT Debian 1:6.1.63-1+rpt1 (2023-11-24) aarch64 GNU/Linux
CmaTotal: 524288 kB CmaFree: 474212 kB
RPI4B-4GB
import sys sys.path.append('/home/pi/fotobox/picamera2') from picamera2 import Picamera2, Preview from libcamera import Transform import time
for i in range(10): picam2 = Picamera2()
preview_config = picam2.create_preview_configuration(main={"size": (3840, 2160)})
picam2.configure(preview_config)
picam2.set_controls({"AfMode": 2 ,"AfTrigger": 0})
picam2.start_preview(Preview.QTGL, x=0, y=0, width=1920, height=1080, transform=Transform(hflip=1))
picam2.start()
picam2.capture_file("test.jpg")
time.sleep(2)
picam2.stop_preview()
picam2.close()
time.sleep(2)
After two runs, error of above occurs
Thanks for the clarification. Yes, I can reproduce that. Is this a new failure, or has it always been like this, do you know? Thanks.
The first time i used picamera2 was by the end of december 23
The problem is related to closing down the QTGL preview window (the non-GL Qt version, as well as the DRM version, are all fine). EGL (or someone) appears to hold onto to references to image buffers for reasons I don't understand. TBH I'm not sure if it's always done this, or if it's a new "feature", I'm slightly suspecting the latter. I'll have to find someone who know about the 3D graphics stack and how it uses Linux dmabufs.
In the meantime the only workaround I have is to avoid closing that preview window. If you can start the camera only once per process then you can configure, re-configure, start, stop the camera as often as you like.
You could try this PR: https://github.com/raspberrypi/picamera2/pull/981
I did find something after rooting around in some stuff I have no understanding of!
Yeah, it works! Thank you so much!!!
Great, I'll merge that onto next then, and it'll appear in the next release (for those who don't want to install pre-release versions from the next branch).
Describe the bug Every time I initialize Picamera2 with a new camera_num, more memory seems taken by the Picamera2 object. Eventually the system runs out of memory and I get a
OSError: [Errno 12] Cannot allocate memory
error.To Reproduce
Expected behaviour Expected that this script could run forever without an error.
Console Output, Screenshots
Hardware : RPi 4. Gen3 wide angle and Gen2 camera connected to an Arducam Camera Board V2.2
Additional context