开发者

Is it possible to replace the memory allocator in a debug build of an MFC application?

开发者 https://www.devze.com 2022-12-19 07:28 出处:网络
I\'d like to make use of Electric Fence in an MFC application. I\'d like to track new/ delete, and if I can track malloc/ free that\'s an added bonus.

I'd like to make use of Electric Fence in an MFC application. I'd like to track new/ delete, and if I can track malloc/ free that's an added bonus.

Unfortunately, MFC redefines new and delete - but using macros (DEBUG_NEW) - so I can't use the standard C++ method of redefining them. (MFC defines them to have different signatures, with source file and line numbers as additional parameters).

Is there any way to force all new/ deletes to go via my allocator, and stop MFC trying 开发者_开发技巧to grab these allocators?


You can stop the MFC hooking of new by redefining DEBUG_NEW in the end of stdafx.h

#undef DEBUG_NEW
#define DEBUG_NEW new
0

精彩评论

暂无评论...
验证码 换一张
取 消