opencv / opencv

Open Source Computer Vision Library
https://opencv.org
Apache License 2.0
75.69k stars 55.61k forks source link

features2d: reduce accuracy test avg memory consumption #25424

Closed mshabunin closed 2 weeks ago

mshabunin commented 2 weeks ago

Merge with contrib: https://github.com/opencv/opencv_contrib/pull/3722

I've observed high memory consumption in the opencv_test_features2d (x86_64, Ubuntu 22.04, Debug):

image It's always more than 180 MiB with peak at 535 MiB

This was caused by pointers to the algorithm object instances stored in the tests parameters. I've replaced them with factory functions/lambdas with the following result:

image Now peak is at 355 MiB and permanent consumption level is ~ 1-2 MiB

Note: current peak is caused by KAZE features allocating 8x image size utility buffers. Not sure if we can or should do anything about it: https://github.com/opencv/opencv/blob/66fb5021e9253e3decab376d00322eaf2b279c89/modules/features2d/src/kaze/KAZEFeatures.cpp#L61-L68

mshabunin commented 2 weeks ago

Apparently xfeatures2d tests directly use features2d test, so that has to be fixed too: opencv/opencv_contrib#3722