有多个终端同时对服务器sql server 2000的一个表进行插入操作,结果在终端上发生内存泄漏,这是怎么回事?
其中有一个字段存的是图片数据
m_pRecordset->AddNew();
m_pRecordset->PutCollect("PlateNum",_variant_t(DB_PlateNum));
m_pRecordset->PutCollect("HaveTime",_variant_t(DB_HaveTime));
m_pRecordset->PutCollect("PlateType",_variant_t(real_DB_PlateType));
m_pRecordset->PutCollect("PlateColor",_variant_t(DB_PlateColor));
m_pRecordset->PutCollect("LaneNum",_variant_t(DB_LineNum));
m_pRecordset->PutCollect("PortNum",_variant_t(real_DB_PortNum));
m_pRecordset->PutCollect("ImgName",_variant_t(DB_ImgName));
m_pRecordset->PutCollect("IsWarning",_variant_t(DB_Iswarning));
m_pRecordset->PutCollect("Ctype",_variant_t(real_DB_Ctype));
CFileException e;
OutputDebugString("debug 1");
if(fwdb.Open(SA_Path_N, CFile::modeRead ¦ CFile::typeBinary, &e)) //打开了一个近景jpg文件
{
int nSize = fwdb.GetLength(); //先得到jpg文件长度
BYTE * pBuffer = new BYTE [nSize]; //按文件的大小在堆上申请一块内存
// BYTE pBuffer[1024*300];
if (fwdb.Read(pBuffer, nSize) > 0 ) //把jpg文件读到pBuffer(堆上申请一块内存)
{ // +----------------------------------------------
VARIANT varBLOB;
SAFEARRAY *psa;
SAFEARRAYBOUND rgsabound[1];
if(pBuffer)
{
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = nSize;
psa = SafeArrayCreate(VT_UI1, 1, rgsabound);
for (long i = 0; i < (long)nSize; i++)
SafeArrayPutElement (psa, &i, &pBuffer[i]);
varBLOB.vt = VT_ARRAY ¦ VT_UI1;
varBLOB.parray = psa;
m_pRecordset->GetFields()->GetItem("NImgData")->AppendChunk(varBLOB);//把jpg文件插入到数据库中
OutputDebugString("debug 4");
}
}
if(NULL!=pBuffer)
delete [] pBuffer; //删掉堆上申请的那一块内存
fwdb.Close();
}