Skip to content

Memory leak in cv2.getWindowImageRect on Mac M1 Air #26574

@Fafa87

Description

@Fafa87

System Information

OpenCV python version: 4.10.0
Operating System / Platform: MacOS Sonoma 14.2
Python version: 3.10

Detailed description

I have made a simple highgui functionality to keep/restore aspect ratio after changing the size of the Window.
It uses:

  • cv2.getWindowImageRect(self.window_name)
  • cv2.resizeWindow(self.window_name, width=nw, height=nh)

However even if it never changes and only calls cv2.getWindowImageRect the memory grows like 100MB every few seconds.
I did not experience it on Windows.

Steps to reproduce

Set up the window: cv2.namedWindow(self.window_name, cv2.WINDOW_NORMAL)
In reading image and processing loop:

            rect = cv2.getWindowImageRect(self.window_name)
            x, y, w, h = rect
            nh = int(round(w * self.aspect_ratio_yx))
            nw = int(round(nh / self.aspect_ratio_yx))

           window.show_image(image)
           key = cv2.waitKey(1)

Issue submission checklist

  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files (videos, images, onnx, etc)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions