OpenCV release vector memory inexplicable crash problem

Source: Internet
Author: User


When I want to release the memory of the vector of the member variable by swap, it is always crash, and the breakpoint goes in the crash position is also very strange:

Crash Location:


I thought it was an issue with memory misalignment, and the result was added

#pragma pack (4)	//1, 2, 4
Also in vain ... t_t

Automatic release of vector for local variables Crash position:



And the same code is normal on OpenCV 3.1.0.


Strange I was almost suspicious of people Sen when, finally God let me find this article.

See the last sentence, only to recall that their own OpenCV2.4.12 is compiled by VS2012 (originally Opencv+cuda, found that the highest support only VS2013, and I on the machine except VS2015 is VS2012, so VS2012 is set as the default CMake compiler), and its own default development IDE is VS2015, which leads to such a bizarre problem ... (This is also the reason why a similar cout will crash when printing the Mat)


Record only to prevent recidivism

Attached: Accidental Harvest


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.