Skip to content

unicam: CMA Memory leak #3220

@kbingham

Description

@kbingham

Describe the bug
Capturing through the unicam driver leaks CMA memory after the device is closed.

To reproduce

  • Build libcamera
  • Identify current CMA consumption
    • cat /proc/meminfo | grep Cma
  • Run qcam for a bit then exit
    • ./build/src/qcam/qcam
  • Calculate difference in CMA usage
    • cat /proc/meminfo | grep Cma
    • echo $((198732-187880))
      • 10852
    • Each repeated launch consumes another ~10mB of CMA.

Expected behaviour
There should be no considerable consumption of CMA when an application closes and releases buffers.
(even if there is a bug in libcamera, the driver should have released all resources on close)

Actual behaviour

Each iteration and launch of qcam (from libcamera) consumes about 10mB from CMA. I doubled the allocation on the unicam from 4 buffers of 1080p to 8 buffers of 1080p, and the memory leak doubled to ~20mB per iteration.

System

  • Which model of Raspberry Pi? e.g. Pi3B+, PiZeroW

    • RPi 3 with Camera v2
  • Which OS and version (cat /etc/rpi-issue)?

    • Raspberry Pi reference 2019-07-10
  • Which firmware version (vcgencmd version)?

Jul  9 2019 14:42:57 
Copyright (c) 2012 Broadcom
version 6c3fe3f096a93de3b34252ad98cdccadeb534be2 (clean) (release) (start_x)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions