5

Right now I'm trying to get two open source project to work together (OBS & OpenCV), but I'm running into a problem here.

To my best understanding OBS overrides the new and delete function. And it's not getting along with the object from OpenCV. It causes some segmentation fault I can't really understand.

So is it possible to use the default new and delete function in a certain section of the code? The usage of OpenCV in my project is limited to a thread, so if it's possible to tell the compiler I want to use default new and delete for a certain function then it should be okay. I'm wondering if it's possible to do such a thing with namespace, but I'm not familiar with C++ at all so I don't have the knowledge on how to do that.

To give more detail on the problem I'm facing, I'm using OpenCV 2.4.11 (tried 3.0.0, but it's basically the same situation), Visual Studio 2013 under Win 7 x64. When I dynamically link the library to OBS, the face detecting thread (which I need to call OpenCV) produces segmentation fault when deleting some objects. When I statically link the library (a suggestion from others), the program crashes at startup inside OpenCV code in some dynamical initialization, because the customized memory manager haven't been initialize yet.

There were other questions that's close to what I'm facing, but they don't seem to solve the issue. I'll leave the links down here: Ignore globally overridden new/delete , a library forces global overloads of new/delete on me!

The link to OBS I'm using is here https://github.com/jp9000/OBS/commit/9ab069c961c768fcdbc53b8ab2cd58540e1ee1f0

Community
  • 1
  • 1
user2535650
  • 265
  • 1
  • 2
  • 8
  • You can not: it is a replacement: http://stackoverflow.com/questions/4134195/how-do-i-call-the-original-operator-new-if-i-have-overloaded-it You can try move "new" thread into separate process, or comment custom new(s), or use placement new in all other cases with using malloc – VladimirS Mar 05 '16 at 23:29
  • Maybe you can store a function pointer to the original new and delete Operator and then call it therewith. https://stackoverflow.com/questions/6604911/is-it-possible-to-create-a-function-pointer-to-the-a-functions-new-operator-c – milbrandt Jul 16 '17 at 19:22

0 Answers0