Hello, I use plugin architecture in my application, which basically have two part.
1 main (c++ runtime library binded statically "option is MTd in visual studio")
2 processing (c++ runtime library binded statically "option is MTd in visual studio")
in main: I create objects, use them in functions etc...
in processing: some of the data created at main module may passed to processing module and can be deleted in processing module.
two different dll use their own heap (because of the MTd option), trying to delete a memory block in processing module, which is created in main module causes this
"*int _CrtIsValidHeapPointer() - verify pointer is from 'local' heap" -> returns false which triggers an assert.
Switching from MTd (a static binding of the runtime library) to MDd (dynamic binding) solves the problem, because all libraries start using same heap. However what should I do if I wanted to statically bind all modules of the library to an executable project ? Every static module uses their own heap hence I get errors.
You're probably creating new objects with new and releasing them with delete directly.
An alternative strategy is to use a factory that has create and release methods which are not inlined (and thus live in a given module and use the same memory pool).
Another alternative is to define new and delete methods on your object that are not inlined. Then define them in the same module. The implementation can just call the global versions, it doesn't matter what heap they use, as long as it's the same one.
Then you'll use whatever memory model, module layout or runtime library options you like.