vector release Ben collapse

Question: program Ben collapse, error: Thread 0x9e90 has exited, the return value -1073740777 (0xc0000417).

Process: Debugger, when exiting a function, the program quit unexpectedly, F11 follow-up was found to be caused when the vector variable release Ben collapse.

The reason: https://blog.csdn.net/lanbing510/article/details/40585789

The _CrtIsValidHeapPointer function is used to ensure that a specific memory address is within the local heap. The local heap refers to the heap created and managed by a particular instance of the C run-time library. If a dynamic-link library (DLL) contains a static link to the run-time library, it has its own instance of the run-time heap, and therefore its own heap, independent of the application's local heap. When _DEBUG is not defined, calls to _CrtIsValidHeapPointer are removed during preprocessing.

Since dll independent of the program, it can not be released outside the dll of stack space.

The space vector variables can not be released by the OpenCV function imencode ( ". Jpg", src, buf, param) application can not be released outside.

The article also pointed out another possible version of VS version and OpenCV different cause.

Resolution: Before using imencode, not allocated space vector variables std :: vector <BYTE> buf = std :: vector <BYTE> (DataSize);

Guess you like

Origin www.cnblogs.com/zzx-blog/p/11455483.html