Sign in to follow this  
quack

mfc with external memory manager

Recommended Posts

how can i use MFC for guid and have my code still use my memory manager? you may find issues with how i have things setup. i overloaded new and new [] and delete delete [], they allocate memory in their own way which isn't important. i needed to overload delete and delete [] so they could properly remove the memory that was setup as well as call the destructors. from the new new[]. outside of MFC this works ok for my needs but with MFC it uses it's own overloaded delete which causes an linker issue. (symbol delete already defined). side note if you uses new[] then you must use delete[] as the compiler put's its own bookkeeping info in there (to keep track of the number of destructors to call etc). this may not be possible and i may have to go a different way without overloading new/delete. if you have an idea please let me know. quack

Share this post


Link to post
Share on other sites
i know that i could overload in the scope of a specific class but do not wish to derive everthing that requires dynamic allocation from this.


quack

Share this post


Link to post
Share on other sites
nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in MMem.obj
nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete[](void *)" (??_V@YAXPAX@Z) already defined in MMem.obj

where mmem is my file

nafxcwd (some mfc file) has it's own definition of delete. which most likely other compeonents of mfc depend upon. msdn had an article posted about forcing link order for this error (overloading delete with mfc). I'm not sure how that works or even if it makes sense.

thanks

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
i use a 3rd party memory manager with mfc apps and one of its notes states that:

"When trying to override new/delete under MFC (which has its own version of global new/delete) the linker will complain. Inorder to fix this error, use the compiler option: /FORCE, which will force it to build an executable even with linker errors. Be sure to check those errors each time you compile, otherwise, you may miss a valid linker error." and "With MFC applications, you will need to comment out any occurance of "#define new DEBUG_NEW" from all source files."

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this