Improved Mat::release()#2901
Improved Mat::release()#2901nisargthakkar wants to merge 3 commits intoopencv:2.4from nisargthakkar:bug_3757
Conversation
|
dims should not be cleared, it may lead to memory leak or memory access violation. please, fix it. Also, for some reason one of the tests fails with your patch: http://pullrequest.opencv.org. Please, take a look at it. |
|
And what about the flags? Is it ok to clear it? |
|
And if we are keeping |
|
We can also free |
|
the code still does not pass our tests; such changes when you try to modify behavior of very basic methods, used everywhere in the library, should be thought out and done very, very carefully. Let's just use m.empty() to check whether matrix is empty or not. And let me close this PR. |
@SpecLad, @ilya-lavrenov I tried to understand what was going on in the
.create()of theMatclass. From what I understood, if the current object has the same number ofrowsandcols[or samesize[i]for eachi] as the one specified in the function call, we need not reallocate space. But, if atleast one is different, it calls.release()first and then allocates the required memory spaces. So, considering this, if an object is released, we want it to be reset to initial conditions.Now,
rowsandcolsare also made zero because ifdims> 2, they are both equal to -1 and are not reset by the previously changed code.This is a continuation of #2891