首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

help! 在程序运作结束后(系统自动回收堆空间时报错)

2013-06-26 
help!!! 在程序运行结束后(系统自动回收堆空间时报错)本帖最后由 u010917465 于 2013-06-11 10:49:20 编辑

help!!! 在程序运行结束后(系统自动回收堆空间时报错)
本帖最后由 u010917465 于 2013-06-11 10:49:20 编辑 [img=http://][/img]
//这是报错时系统自动弹出的代码:
/***
*free.c - free an entry in the heap
*
*       Copyright (c) Microsoft Corporation. All rights reserved.
*
*Purpose:
*       Defines the following functions:
*           free()     - free a memory block in the heap
*
*******************************************************************************/

#include <cruntime.h>
#include <malloc.h>
#include <winheap.h>
#include <windows.h>
#include <internal.h>
#include <mtdll.h>
#include <dbgint.h>
#include <rtcsup.h>

/***
*void free(pblock) - free a block in the heap
*
*Purpose:
*       Free a memory block in the heap.
*
*       Special ANSI Requirements:
*
*       (1) free(NULL) is benign.
*
*Entry:
*       void *pblock - pointer to a memory block in the heap
*
*Return:
*       <void>
*
*******************************************************************************/

void __cdecl _free_base (void * pBlock)
{

        int retval = 0;


        if (pBlock == NULL)
            return;

        RTCCALLBACK(_RTC_Free_hook, (pBlock, 0));

        retval = HeapFree(_crtheap, 0, pBlock);//最后一个箭头指到这儿,蛋疼!!!
        if (retval == 0)
        {
            errno = _get_errno_from_oserr(GetLastError());
        }
}
释放堆空间?MFC?free.c
[解决办法]
释放了一个指针,这个指针所指的内存,不是用malloc等内存管理函数分配的内存。
查看一下那个指针是啥东西。

是否已经施行过加减运算,或者干脆就是随便拿过来的一个数值,
或者一个不用释放的指针(指向局部变量的指针,指向全局变量的指针),
甚至是野指针。

[解决办法]
在运行结束后报错,基本都是内存释放的问题!

热点排行