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

这是内存 泄露吗?处有未经处理的错误: Microsoft C++ 错误: 内存位置 0x0012f280 处的 std:bad_alloc

2013-08-04 
这是内存 泄露吗?处有未经处理的异常: Microsoft C++ 异常: 内存位置 0x0012f280 处的 std::bad_alloc。错

这是内存 泄露吗?处有未经处理的异常: Microsoft C++ 异常: 内存位置 0x0012f280 处的 std::bad_alloc。
错误    :
“处有未经处理的异常: Microsoft C++ 异常: 内存位置 0x0012f280 处的 std::bad_alloc。”
      * Put the new entry into the table and update the end-of-table
         * pointer.
         */
         *(onexitend++) = (_PVFV) EncodePointer(func);
        __onexitend = (_PVFV *) EncodePointer(onexitend);

        return func;

vector<CAA::pc>* CGetPointsCloud::MyGetRegPoints(int IMx,int IMy,int Ptdentity)
{
//*******获取文件名
char* m1="D:\\test2\";
char* type=".dat";
char* fh="_";
char*path=NULL;
char temp[80];
_snprintf(temp,79,"%s%d%s%d%s%d%s",m1,Ptdentity,fh,IMx,fh,IMy,type);temp[79]=0;
path=(char *)temp;


vector<pc> *IPtCloud=new vector<pointcloud>;

FILE *RegFile=fopen(path,"rb+");
if(RegFile!=NULL)
{
fseek(RegFile,0,SEEK_END);
long flength=ftell(RegFile);
long Isize=sizeof(pointcloud);
         int headsize=sizeof(head);
int ptlength=(flength-headsize)/Isize;

fseek(RegFile,headsize,0);
for(int k=0;k<ptlength;k++)
{
pointcloud Pttemp;
fread(&Pttemp,sizeof(pointcloud),1,RegFile);
IPtCloud->push_back(Pttemp);//错误********
}

fclose(RegFile);
}
return IPtCloud;
}

函数调用

vector<CAA::pc>* PointsResult=NULL;
CAA * m_GetPointsCloud=new CGetPointsCloud;
PointsResult=m_GetPointsCloud->MyGetRegPoints(Mx,My, PointDensity);
delete PointsResult;


第一次 调用没错 ,第二次调用就报这个错?这是什么问题?指针空间没有释放?还是内存不够?
[解决办法]
引用:
Quote: 引用:


看代码前我先猜是堆内存访问越界


如何解决?我读取一个非常大非常大的文件数据


内存有限, 使用的时候要珍惜. 大文件用到哪部分对哪部分, 别一口气都读到内存里面撒.

热点排行