Original Post
I know debug mode always makes your program run slower but this is ridiculous, my program is running about 100x slower! I know what the source of the problem is, but I don't know why it's cause such a huge slowdown. Basically, I have a memory manager and within it, I represent units of data allocated on the heap by an abstract representation called CDataObject. Now in order to have proper deletion, this class has a function pointer to a function that contains the data's type and array/not array information. It is assigned by my smart pointer class when a piece of data is created an assigned to one. It sorta looks like this:
template<class Type>
void DeleteData(void* Data)
{
delete (Type*)Data;
}
template<class Type>
void DeleteArray(void* Data)
{
delete [] (Type*)Data;
}
class CDataObject
{
void (*varDelete)(void*);
.....
}; So when the smart pointer, which is template class and there is an array and non-array version, gets a piece of newly created data it sets the appropriate function to the CDataObject's function pointer varDelete. Then when the garbage collection cycle determines the data needs to be deleted, it just called the function pointer passing the data's address. Now when running in normal mode it's very fast, but in debug ludicrously slow. Any reason why, and any ways I can improve my memory manager to prevent this?