Closed mgineer85 closed 3 weeks ago
When changing the while loop to the following, it will work endlessly for me. Endless translates to 10 minutes currently ;)
i = 0
while True:
i += 1
_switch_mode(_capture_config)
# in capture mode, get frame and metadata
data = io.BytesIO()
with _picamera2.captured_request(wait=1.5) as request:
# Do something with the request.
print(request)
request.save("main", data, format="jpeg")
print(request.get_metadata())
# _picamera2.capture_file(data, format="jpeg")
_ = data.getbuffer()
# comment to run out of cma memory slower, but script died for me after ~40 loops.
# _metadata = _picamera2.capture_metadata(wait=1.5) # with this line the script works about 10 loops only.
# The request is released automatically when we leave the scope of the "with".
print(f"got capture frame #{i}")
_switch_mode(_preview_config)
# in preview mode, get frame indirect via filewriter and metadata here
_metadata = _picamera2.capture_metadata(wait=1.5)
Did I do something illegal by requesting the metadata right after a capture separately?
Hi, thanks for reporting this.
Yes, I think there might be something leaking there, so we'll have to look into that. In the meantime, a workaround (which may actually be better regardless in this sort of scenario) might be to use the "persistent allocator". This will allocate the buffers for each use case ("preview" or "still") just once, and hang on to them.
To do this, add:
from picamera2.allocators import PersistentAllocator
and create the Picamera2 object with
_picamera2 = Picamera2(allocator=PersistentAllocator())
@will-v-pi Could I ask you to have a look at the regular DmaAllocator in this particular case? Thanks!
Can confirm that it works with the PersistentAllocator continuously. The CmaFree never drops below ~250MB.
Will use this until this issue is solved. Thank you very much!
Describe the bug Hello @davidplowman, as per request, I create a separate issue about my issue running out of CmaMemory.
With reference to this issue comment in #1102 that is dedicated to the Pi 5. I am on a Pi 4 currently.
To Reproduce Following script dies after about 10 loops:
During script runtime, you see the Cma is getting lower and lower, finally the script fails and the CmaMemory is free again:
Expected behaviour Script not dying ;)
Console Output, Screenshots
Hardware : Raspberry Pi 4 and IMX708 original camera module.