首页 相关文章 VC++6.0 之NEW调用的BUG(不停调用NEW的朋友们看过来)

VC++6.0 之NEW调用的BUG(不停调用NEW的朋友们看过来)

_heap_alloc_debug 会使程序崩溃调。所有版本的VC++6.0。
new中调用了._malloc_dbg(), 和_heap_alloc_dbg().
在_heap_alloc_dbg()中有个静态的long 型计数器, _lRequestCurr (Microsoft visual StudioVC98CrtSrcdbgheap.c),初始化为1。
每次new()或 malloc()调用,这个计数器加1,当你的程序运行到足够时间,这个值会在 -2,147,483,648 to 2,147,483,647之间。
问题在于如下的代码 _heap_alloc_dbg():
/* break into debugger at specific memory allocation */
if (lRequest == _crtBreakAlloc)
_CrtDbgBreak();
lRequest 初始化为_lRequestCurr,_crtBreakAlloc 初始化为-1,当程序启动时。

每次 malloc(), lRequest (_lRequest...[ 查看全文 ]

2016-02-19 标签:

VC++6.0 之NEW调用的BUG(不停调用NEW的朋友们看过来)的相关文章

手机页面
收藏网站 回到头部