Skip to content

Set and check allocator pointer for all cv::Mat instances#25979

Merged
asmorkalov merged 1 commit intoopencv:4.xfrom
asmorkalov:as/custom_allocator
Aug 5, 2024
Merged

Set and check allocator pointer for all cv::Mat instances#25979
asmorkalov merged 1 commit intoopencv:4.xfrom
asmorkalov:as/custom_allocator

Conversation

@asmorkalov
Copy link
Copy Markdown
Contributor

@asmorkalov asmorkalov commented Aug 1, 2024

Current implementation does not initialize cv::Mat::allocator filed even, if non standard allocator is used globally.

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

@asmorkalov
Copy link
Copy Markdown
Contributor Author

@opencv-alalek I added check for ROI and deallocate counters to check leaks.

Copy link
Copy Markdown
Contributor

@opencv-alalek opencv-alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
u = a->allocate(dims, size, _type, 0, step.p, ACCESS_RW /* ignored */, USAGE_DEFAULT);
CV_Assert(u != 0);
allocator = a;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

umatrix.cpp has the similar code related to Mat (besides of tons of code related to UMat): https://github.com/opencv/opencv/blob/4.10.0/modules/core/src/umatrix.cpp#L601

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UMat handles allocators a bit different. I propose to handle it with dedicated PR. Need to discuss it first.

@asmorkalov asmorkalov force-pushed the as/custom_allocator branch from 13c17a2 to a15cd4b Compare August 5, 2024 07:07
@asmorkalov asmorkalov merged commit ab99f87 into opencv:4.x Aug 5, 2024
@asmorkalov asmorkalov mentioned this pull request Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants