template <class T>
class X
{
*T mData;
~X()
{
if (mData)
delete mData;
}
};
Deleting template class in dll makes runtime error
I have a template class that worked well before exporting to dll. But after that it makes runtime error when calling destructor.
It looks like :
Can you help me finding how could this be happened ?
mData is probably allocated in the exe. You can't allocate memory in the exe and deallocate it in the DLL (or vice-versa), because with the static linked CRT, the DLL and exe get different heaps. Free the memory from the exe, allocate it in the DLL, or use the DLL version of the CRT - but you'll have to make sure both apps link with the exact same version, i.e. You can't have one linked with the single threaded debug CRT and one with the multithreaded debug, and you can't mix debug/release versions and compiler versions.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement